Python 更改文件格式
根据groupby需求提供以下输出Python 更改文件格式,python,pandas,Python,Pandas,根据groupby需求提供以下输出 2021-04-19负20 正7 2021-04-20负104 正70 2021-04-21负64 阳性53 2021-04-22负115 正50 我想得到一个包含列的新数据帧 'created_at'、'positive'、'negative', 2021-04-19 7 20 2021-04-20 70 104 等等 我很感谢你的回答。你似乎想pivot\u table(): out
2021-04-19负20
正7
2021-04-20负104
正70
2021-04-21负64
阳性53
2021-04-22负115
正50
我想得到一个包含列的新数据帧
'created_at'、'positive'、'negative',
2021-04-19 7 20
2021-04-20 70 104
等等
我很感谢你的回答。你似乎想
pivot\u table()
:
output = df.reset_index().pivot_table(index='created_at',columns='sentiment',values='name_of_the_series')