Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/352.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_Python 2.7_Pandas - Fatal编程技术网

Python 熊猫透视表

Python 熊猫透视表,python,python-2.7,pandas,Python,Python 2.7,Pandas,当我在Windows上使用Pandas运行我的代码时,它工作得很好,但是在Ubuntu上运行时,我得到以下错误: canceled_Table = pd.pivot_table(canceled, index = 'end', columns = 'pcode', values = 'quantity', aggfunc = np.sum) TypeError:pivot_table()获得意外的关键字参数“index” 有人知道为什么吗?很可能您的pandas版本不同,在windows上运行

当我在Windows上使用Pandas运行我的代码时,它工作得很好,但是在Ubuntu上运行时,我得到以下错误:

canceled_Table = pd.pivot_table(canceled, index = 'end', columns = 'pcode', values = 'quantity', aggfunc = np.sum)
TypeError:pivot_table()获得意外的关键字参数“index”


有人知道为什么吗?

很可能您的pandas版本不同,在windows上运行的是
0.16.0
或更高版本,而您的ubuntu版本更旧。api在中发生了变化,较旧的api使用了
,但为了一致性,这分别更改为
索引

您可以升级或尝试以下操作:

canceled_Table = pd.pivot_table(canceled, rows = 'end', cols = 'pcode', values = 'quantity', aggfunc = np.sum)

你在ubuntu上运行的是旧版本的pandas吗?您可以发布pandas.\uuuu version\uuuuu,如果您运行的版本早于
0.16.0
,则参数名称不同,请尝试
cancelled\u Table=pd.pivot\u Table(cancelled,rows='end',cols='pcode',values='quantity',aggfunc=np.sum)
,请参阅