Answers for "Transform the categorical variables to dummy variables (dropping one of the levels for each variable) in pnadas"

6

getting dummies and input them to pandas dataframe

note:
dummies = pd.get_dummies(df[['column_1']], drop_first=True)
df = pd.concat([df.drop(['column_1'],axis=1), dummies],axis=1)


note:for more that one coloum keep ading in the list 
dummies = pd.get_dummies(df[['column_1', 'column_2','column_3']], drop_first=True)
df = pd.concat([df.drop(['column_1', 'column_1'],axis=1), dummies],axis=1)
Posted by: Guest on May-11-2020

Code answers related to "Transform the categorical variables to dummy variables (dropping one of the levels for each variable) in pnadas"

Python Answers by Framework

Browse Popular Code Answers by Language