-3
df=pd.DataFrame(pd.read_csv("C:/Users/POP/Desktop/survay of consumers/2018/public2018.csv",header=0,encoding = 'unicode_escape'))
df1=df.iloc[:,['B2','D1E','GE2_d','ppagect4','ppeducat','ppethm','ppgender','ppinccat6','ppreg9','ppwork']]
df1

TypeError: cannot perform reduce with flexible type

Andrej Kesely
  • 118,151
  • 13
  • 38
  • 75

1 Answers1

0

With .iloc, you select columns based on their position. You should instead use

df1=df[['B2','D1E','GE2_d','ppagect4','ppeducat','ppethm','ppgender','ppinccat6','ppreg9','ppwork']]
ignoring_gravity
  • 3,886
  • 3
  • 24
  • 40