Good Morning
Im trying create a new dataframe with some datas of another dataset (csv file in fact). In the code below, i put df[1]
and df[3]
because my intention is a new dataset with only these two columns of the csv file(second and forth column)
P.S: The original Dataset contains 75 columns
**
import pandas as pd
df = pd.read_csv(r'C:\Users\krist\OneDrive\Área de Trabalho\Programação\Python\NFe_E_V3_00626708_20220801_20220830.csv', encoding='latin1', sep=';')
dfreduz = pd.DataFrame(df[1], df[3])
print(dfreduz)
CodePudding user response:
Try this one to select columns based on indexes:
dfreduz = df.iloc[:, [1, 3]]
CodePudding user response:
you would need to call the columns by name example:
dfreduz = pd.DataFrame(df["name"], df["job"])
make sure to use quotation marks "