Home > Software engineering >  get-dummies() getting applied on float parameter
get-dummies() getting applied on float parameter

Time:05-06

I have a dataset which contains both numerical and categorical values , but when I apply pd.get_dummies(), I am getting dummies of a parameter which contains float value as well.

I tried inserting individual parameters into get_dummies(df ,columns=[p1 , p2 , p3 ..]) and it works fine, but is there a proper solution for get_dummies to ignore a single parameter?

CodePudding user response:

Maybe you can use select_dtypes to include / exclude columns:

out = pd.get_dummies(df.select_dtypes(exclude='float'))

CodePudding user response:

IIUC use:

out = pd.get_dummies(df.drop('col_not_need', axis=1))
  • Related