'for loop only saving last value of last variable
i am using one hot encoding for mercedes-benz dataset kaggle for three columns in a for loop but when use pd.get_dummies in a for loop the one hot encoding applies for "X6" column only. i assume it is iterating through other two "X3" and "X4" as well but it is not making change into dataframe. X3 has 3 columns X4 has 4 columns and X6 has 12 columns.
for column in ['X3', 'X4','X6']:
dummies = pd.get_dummies(df[column])
df[dummies.columns] = dummies
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
