I've tried two things so far without luck to convert column values to dummies.
So I'm trying to dummify personal interests.
uf = uf['personal_interests'].str.join('|').str.get_dummies()
print(uf)
or
mlb = MultiLabelBinarizer()
mlb.fit(['body','men_skincare','tools','hand','makeup','hair', 'nail', 'skincare','men_fragrance','fragrance','foot'])
list(mlb.classes_)
print(mlb.classes_)
uf = pd.DataFrame(mlb.fit_transform(uf['personal_interests']),columns=mlb.classes_, index=uf.index)
print(uf)
In both situations I get this:
Rather than an output like this: Output
source https://stackoverflow.com/questions/73338807/convert-a-column-of-list-to-dummies-by-group-not-character
Comments
Post a Comment