利用Python进行数据分析》第二章,处理MovieLens 1M数据集,有句代码总是报错:

mean_rating = data.pivot_table('rating', rows='title', cols='gender', aggfunc='mean')

报错信息如下:

Traceback (most recent call last):
  File "D:\Users\wangshuang829\AppData\Local\Continuum\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3035, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-47-d6e7435a4a95>", line 1, in <module>
    mean_rating = data.pivot_table('rating', rows='title', cols='gender', aggfunc='mean')
TypeError: pivot_table() got an unexpected keyword argument 'rows'

修改办法:rows改成index,cols写成全名”columns”

mean_rating = data.pivot_table('rating', index='title', columns='gender', aggfunc='mean')

修改后得到正确处理结果:

gender                                F         M
title
$1,000,000 Duck (1971)         3.375000  2.761905
'Night Mother (1986)           3.388889  3.352941
'Til There Was You (1997)      2.675676  2.733333
'burbs, The (1989)             2.793478  2.962085
...And Justice for All (1979)  3.828571  3.689024

TypeError: pivot_table() got an unexpected keyword argument 'rows'的更多相关文章

  1. TypeError: parse() got an unexpected keyword argument 'transport_encoding'

    错误: TypeError: parse() got an unexpected keyword argument 'transport_encoding'You are using pip vers ...

  2. TypeError: __init__() got an unexpected keyword argument 't_command'

    python  .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...

  3. TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'

    错误: TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations' 参照https://blog.c ...

  4. TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'

    在学习莫烦教程中keras教程时,报错:TypeError: to_categorical() got an unexpected keyword argument 'nb_classes',代码如下 ...

  5. TypeError: parse() got an unexpected keyword argument 'transport_encoding' 安装tensor后报错

    TypeError: parse() got an unexpected keyword argument 'transport_encoding' 巨蛋疼,出这个问题后,老夫真是醉了,mmp,最后在 ...

  6. Python pika, TypeError: exchange_declare() got an unexpected keyword argument 'type' 问题修复

    网上很多写法都是 type='fanout' 这样的.(这里是基于python=3.6版本, pika=0.13.0 版本) credentials = pika.PlainCredentials(' ...

  7. TypeError: _obtain_input_shape() got an unexpected keyword argument 'include_top'

    报错 Traceback (most recent call last): File "D:/PyCharm 5.0.3/WorkSpace/3.Keras/2.Application中五款 ...

  8. Django TypeError: render() got an unexpected keyword argument 'renderer'

    场景: Xadmin添加plugin 来源: 1. xadmin与DjangoUeditor的安装 (第3.3章节) 2. 增加富文本编辑器Ueditor (第14.7章节) 报错: Django T ...

  9. TypeError: __init__() got an unexpected keyword argument 'serialized_options'

    问题描述: TypeError: __init__() got an unexpected keyword argument 'serialized_options' File "objec ...

随机推荐

  1. ISSCC 2017论文导读 Session 14 Deep Learning Processors,A 2.9TOPS/W Deep Convolutional Neural Network SOC

    最近ISSCC2017大会刚刚举行,看了关于Deep Learning处理器的Session 14,有一些不错的东西,在这里记录一下. A 2.9TOPS/W Deep Convolutional N ...

  2. Tomcat的配置,设置内存,获取用户IP

    一.修改配置文件 tomcat配置文件路径/tomcat/bin/server.xml # shutdown指定终止Tomcat服务器运行时,发给Tomcat 服务器的shutdown监听端口的字符串 ...

  3. jackson序列化字段字母大小写及字段名重复

    一:Jackson默认的属性发现规则将会查找到如下所述的属性: 1.所有被public修饰的字段(成员变量): 2.所有被public修饰的getter(即形如“getXxx()”的方法): 3.所有 ...

  4. 数据结构(十一)B树

    之前的二叉排序树,平衡二叉树都是基于二叉树的实现,但是在搜索过程中,效率和树的深度有关,所以就想到把二叉树改为多叉树,B树和B+树都基于多叉树的实现 多路查找树 B树 定义   应用场景   B+树 ...

  5. 微信小程序:scroll-view的bug

    flex:1并不能使scroll-view的高度固定,需要添加高度height:1rpx(数值大于0)就行

  6. [mybatis]Record与Example的用法

    一.Record 一个Record是一个Dao对象(继承Mapper接口),tkmybatis会将record自动映射成sql语句,record中所有非null的属性都作为sql语句,如: 映射的sq ...

  7. c中%

    %u 十进制无符号整数 %f 浮点数 %s 字符串 %c 单个字符 %p 指针的值 %e 指数形式的浮点数 %x, %X 无符号以十六进制表示的整数 %0 无符号以八进制表示的整数 %g 自动选择合适 ...

  8. python 函数、模块、包及import导入方法

    https://www.cnblogs.com/lijunjiang2015/p/7812996.html

  9. ACM比赛辅导--授课内容

    Lesson1(3月19日) 1.讲解Dev-C++.VC++6.0的单步调试方法 2.学习比赛的基本输入输出,练习C语言网的1085—1092 Lesson2(3月21日) 1.学习挑战程序设计,第 ...

  10. 转载:Javascript面向对象编程原理 -- 理解对象

    源地址:http://www.html-js.com/article/1717 虽然JavaScript中已经自带了很多内建引用类型,你还是会很频繁的需要创建自己的对象.JavaScript编程的很大 ...