Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 更改文件格式_Python_Pandas - Fatal编程技术网

Python 更改文件格式

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

根据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()

output = df.reset_index().pivot_table(index='created_at',columns='sentiment',values='name_of_the_series')