利用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. mysql left join中where和on条件的区别

    left join中关于where和on条件的几个知识点: 1.多表left join是会生成一张临时表,并返回给用户 2.where条件是针对最后生成的这张临时表进行过滤,过滤掉不符合where条件 ...

  2. 20145216史婧瑶《Java程序设计》第8周学习总结

    20145216 <Java程序设计>第8周学习总结 教材学习内容总结 第十五章 通用API 15.1 日志 java.util.logging 包提供了日志功能相关类与接口,不必额外配置 ...

  3. java第四周学习总结

    学号20145336 <Java程序设计>第4周学习总结 教材学习内容总结 继承 继承符合(Don't Repeat Yourself)原则,即在自己的代码中不要重复自己编写的信息,这在多 ...

  4. 如何退出minicom【学习笔记】

    一.先按ctr+a进入设置模式 二.在按x退出

  5. 【转载】showModalDialog returnValue is undefined in Google Chrome

    showModalDialog returnValue is undefined in Google Chrome Posted on August 22, 2012by briancaos For ...

  6. struts2的refreshModelBeforeResult

    首先想介绍的是struts2的原型驱动ModelDriven机制. 所谓的ModelDriven,就是把一个实体类当成页面数据的收集对象.用法看起来像下面这个样子 <span style=&qu ...

  7. 【尺度不变性】An Analysis of Scale Invariance in Object Detection – SNIP 论文解读

    前言 本来想按照惯例来一个overview的,结果看到1篇十分不错而且详细的介绍,因此copy过来,自己在前面大体总结一下论文,细节不做赘述,引用文章讲得很详细,另外这篇paper引用十分详细,如果做 ...

  8. 面试笔试总结(一)之 C++基础

    C++ 1.智能指针 内存管理 垃圾回收 指针问题 资源管理(内存就是资源) 可以通过引用计数的机制...实现内存回收,不要让内存泄漏. 涉及到内存的泄露的问题: 当创建一个对象的时候(new)而在对 ...

  9. 今天 学习用到的一些知识(properties 读取,js 删除元素)

    1.properties文件位置的关系:当properties文件放在src目录下时,编译会自动把src里的文件放到bin文件平级,因此可用this.getClass.getClassLoader.g ...

  10. Memcached incr 与 decr 命令

    Memcached incr 与 decr 命令用于对已存在的 key(键) 的数字值进行自增或自减操作. incr 与 decr 命令操作的数据必须是十进制的32位无符号整数. 如果 key 不存在 ...