简单示例:
d=pd.DataFrame({'brand':['xiaomi','apple','bana'],
'type1':['a','b','c'],
'type2':['e','f','g']})
d
Out[114]:
brand type1 type2
0 xiaomi a e
1 apple b f
2 bana c g
我想要的是:
brand a b c
xiaomi e
apple f
bana g
所以我用这个:
pd.pivot_table(d,index='brand',columns='type1',values='type2')
但字符串似乎不能设置为值
目前没有回答
相关问题 更多 >
编程相关推荐