You are not doing anything wrong. MultiLabelBinarizer()
, as most other sklearn
stuff, returns numpy arrays. In this case, the underlying data looks identical to your expected output, sans the ID
and Tag
names.
Use pd.crosstab
instead:
pd.crosstab(df['Id'], df['Tag'])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…