Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.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,我试图在python中传播数据帧的某一列 在R中,我将使用此功能: 在python中,我刚刚找到了df.pivot\u table(),但我刚刚得到一个错误: pandas.pivot_table(df, values= 'Value', index=['Day', 'Money', 'Product'],columns=['Account']) ^ 更新结果: 数据帧没有改变。它只返回

我试图在python中传播数据帧的某一列

在R中,我将使用此功能:

在python中,我刚刚找到了
df.pivot\u table()
,但我刚刚得到一个错误:

   pandas.pivot_table(df, values= 'Value', index=['Day', 'Money', 'Product'],columns=['Account'])
                                                  ^
更新结果: 数据帧没有改变。它只返回了相同的数据帧,没有扩展

考虑到价值列,什么是分散账户列的好方法

Day Money Product   Account              Value 
D01 R$     000013   Volume              96.774194
D02 R$     000013   Volume              96.774194
D03 R$     000013   Volume              96.774194
D04 R$     000013   Volume              96.774194
D05 R$     000013   Volume              96.774194
D06 R$     000013   Volume              96.774194
D07 R$     000013   Volume              96.774194                                                                             
...
D02 R$     000013   PrecoVenda           0.132258
D03 R$     000013   PrecoVenda           0.132258
D04 R$     000013   PrecoVenda           0.132258
D05 R$     000013   PrecoVenda           0.132258
D06 R$     000013   PrecoVenda           0.132258
D07 R$     000013   PrecoVenda           0.132258

索引前忘记了逗号:

pandas.pivot_table(df, values= 'Value', index=['Day', 'Money', 'Product'],columns=['Account'])

这是一个语法错误,您只是在
'Value'
之后缺少一个逗号。对不起,这是真的。但是结果仍然返回相同的DataFrame我现在得到了写入结果