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
1note:
2dummies = pd.get_dummies(df[['column_1']], drop_first=True)
3
4note:for more that one coloum keep ading in the list
5dummies = pd.get_dummies(df[['column_1', 'column_2','column_3']], drop_first=True)
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#this do dummie verable do a very intersting thing they turn calegorical
2#variables in numerical like M and F they can 0 for M and 1 for F
3
4
5pd.get_dummies(df.Gender)
6
7 F M
80 0 1
91 1 0
102 1 0
113 0 1
124 1 0
13... ... ...
14202 1 0
15203 0 1
16204 0 1
17205 0 1
18206 1 0
19207 rows × 2 columns
20
21