Python 熊猫透视表
当我在Windows上使用Pandas运行我的代码时,它工作得很好,但是在Ubuntu上运行时,我得到以下错误: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上运行
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)
,请参阅