“get_dummies” Code-Antworten

Dummies erhalten und sie in Pandas DataFrame eingeben

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)
JAKKA9

Dummies für eine Spalte in Pandas DataFrame erhalten

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)
JAKKA9

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

Kristi

Ähnliche Antworten wie “get_dummies”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen