《利用Python进行数据分析》第二章pivot_table报错问题

来源:互联网 发布:dg加密软件 编辑:程序博客网 时间:2024/05/29 15:25

http://blog.csdn.net/Zhangjunjie789/article/details/47724813

学习《利用Python进行数据分析》第二章的时候,处理1880-2010年间全美婴儿姓名数据,有句代码总是报错:

total_births=names.pivot_table(‘births’,rows=’year’,cols=’sex’,aggfunc=sum)

报错信息如下:

Traceback (most recent call last):

File “”, line 1, in
total_births=names.pivot_table(‘births’,rows=’year’,cols=’sex’,aggfunc=sum)
TypeError: pivot_table() got an unexpected keyword argument ‘rows’

查了有关资料,将rows改成index,cols写成全名”columns”:

total_births=names.pivot_table(‘births’,index=’year’,columns=’sex’,aggfunc=sum)

便可得到正确处理结果

0 0
原创粉丝点击