temp = {'name' : ['Edmond', 'ALex'], 'cat' : [['Horror', 'Vengeance', 'Justice'], ['Romance', 'Sacrifice']]}
df = pd.DataFrame(temp)
df.cat.apply(pd.Series)
df.cat.apply(pd.Series) \
.merge(df, left_index = True, right_index = True)
df.cat.apply(pd.Series) \
.merge(df, left_index = True, right_index = True) \
.drop(['cat'], axis = 1)
df.cat.apply(pd.Series) \
.merge(df, left_index = True, right_index = True) \
.drop(['cat'], axis = 1) \
.melt(id_vars = ['name'], value_name = "cat") \
.drop(['variable'], axis= 1)
0 comments:
Post a Comment