2017-06-22 17 views

答えて

2

あなたはjoinまたはconcatget_dummiesを使用することができます。

df = df[['id']].join(df['amentieis'].str.get_dummies(',')) 
print (df) 
    id Heating Hot tub Internet Shower TV 
0 1  0  0   1  1 1 
1 2  0  1   1  0 1 
2 3  1  0   1  1 0 

または:

df = pd.concat([df['id'], df['amentieis'].str.get_dummies(',')], axis=1) 
print (df) 
    id Heating Hot tub Internet Shower TV 
0 1  0  0   1  1 1 
1 2  0  1   1  0 1 
2 3  1  0   1  1 0 
+0

パーフェクト、ありがとう! –

関連する問題