“PANDAS.GET_DUMMIES” Kode Jawaban

Mendapatkan Dummies dan Masukkannya ke 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)
JAKKA9

cara mendapatkan boneka di panda DataFrame

df = pd.get_dummies(df, columns=['type'])
Bewildered Barracuda

PANDAS.GET_DUMMIES

>>> pd.get_dummies(pd.Series(list('abcaa')), drop_first=True)
   b  c
0  0  0
1  1  0
2  0  1
3  0  0
4  0  0
Annoying Addax

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya