Answers for "get_dummies in python"

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
3

getting dummies for a column in pandas dataframe

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

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)
Posted by: Guest on May-11-2020
0

how to get dummies in a dataframe pandas

df = pd.get_dummies(df, columns=['type'])
Posted by: Guest on September-03-2020
0

get_dummies

#this do dummie verable do a very intersting thing they turn calegorical 
#variables in numerical like M and F they can 0 for M and 1 for F  


pd.get_dummies(df.Gender)

	F	M
0	0	1
1	1	0
2	1	0
3	0	1
4	1	0
...	...	...
202	1	0
203	0	1
204	0	1
205	0	1
206	1	0
207 rows × 2 columns
Posted by: Guest on September-22-2021
1

get dummies pandas

>>> pd.get_dummies(pd.Series(list('abc')), dtype=float)
     a    b    c
0  1.0  0.0  0.0
1  0.0  1.0  0.0
2  0.0  0.0  1.0
Posted by: Guest on April-27-2021
1

python for dummies

A good book I guess, but kinda outdated now.
Posted by: Guest on August-05-2020

Python Answers by Framework

Browse Popular Code Answers by Language