-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
  • 168,389
  • 15
  • 48
  • 91

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
  • 6,677
  • 4
  • 32
  • 65