'get-dummies() getting applied on float parameter
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?
Solution 1:[1]
Maybe you can use select_dtypes to include / exclude columns:
out = pd.get_dummies(df.select_dtypes(exclude='float'))
Solution 2:[2]
IIUC use:
out = pd.get_dummies(df.drop('col_not_need', axis=1))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Corralien |
| Solution 2 | jezrael |
