1note:
2dummies = pd.get_dummies(df[['column_1']], drop_first=True)
3df = pd.concat([df.drop(['column_1'],axis=1), dummies],axis=1)
4
5
6note:for more that one coloum keep ading in the list
7dummies = pd.get_dummies(df[['column_1', 'column_2','column_3']], drop_first=True)
8df = pd.concat([df.drop(['column_1', 'column_1'],axis=1), dummies],axis=1)
9
1>>> s = pd.Series(list('abca'))
2
3>>> pd.get_dummies(s)
4 a b c
50 1 0 0
61 0 1 0
72 0 0 1
83 1 0 0
9
1>>> pd.get_dummies(pd.Series(list('abc')), dtype=float)
2 a b c
30 1.0 0.0 0.0
41 0.0 1.0 0.0
52 0.0 0.0 1.0
6
1>>> pd.get_dummies(pd.Series(list('abcaa')), drop_first=True)
2 b c
30 0 0
41 1 0
52 0 1
63 0 0
74 0 0
8