TypeError: pivot_table() got an unexpected keyword argument 'rows'
利用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'的更多相关文章
- TypeError: parse() got an unexpected keyword argument 'transport_encoding'
错误: TypeError: parse() got an unexpected keyword argument 'transport_encoding'You are using pip vers ...
- TypeError: __init__() got an unexpected keyword argument 't_command'
python .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...
- TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'
错误: TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations' 参照https://blog.c ...
- TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'
在学习莫烦教程中keras教程时,报错:TypeError: to_categorical() got an unexpected keyword argument 'nb_classes',代码如下 ...
- TypeError: parse() got an unexpected keyword argument 'transport_encoding' 安装tensor后报错
TypeError: parse() got an unexpected keyword argument 'transport_encoding' 巨蛋疼,出这个问题后,老夫真是醉了,mmp,最后在 ...
- Python pika, TypeError: exchange_declare() got an unexpected keyword argument 'type' 问题修复
网上很多写法都是 type='fanout' 这样的.(这里是基于python=3.6版本, pika=0.13.0 版本) credentials = pika.PlainCredentials(' ...
- 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中五款 ...
- Django TypeError: render() got an unexpected keyword argument 'renderer'
场景: Xadmin添加plugin 来源: 1. xadmin与DjangoUeditor的安装 (第3.3章节) 2. 增加富文本编辑器Ueditor (第14.7章节) 报错: Django T ...
- TypeError: __init__() got an unexpected keyword argument 'serialized_options'
问题描述: TypeError: __init__() got an unexpected keyword argument 'serialized_options' File "objec ...
随机推荐
- DNSmasq安装配置
dns安装配置yum -y install dnsmasq dns配置文件vi /etc/dnsmasq.confresolv-file=/etc/resolv.dnsmasq.confaddn-ho ...
- kali 安装virtualbox
安装virualbox 的三大步: 1.添加源: Add the following line to your /etc/apt/sources.list: deb http://download.v ...
- 20145214 《Java程序设计》第3周学习总结
教材学习内容总结 对象(Object):存在的具体实体,具有明确的状态和行为 类(Class):具有相同属性和行为的一组对象的集合,用于组合各个对象所共有操作和属性的一种机制 从类看对象:类定义可以视 ...
- 快用Visual Studio(五)- 语言特性
HTML 自带Emment $ SHIFT + OPTION + F:格式化代码 其他语言特性提示 CSS & LESS hover属性,提示样式对象标签 $ CMD + SHIFT + O: ...
- 【读书笔记】《深入浅出nodejs》第三章 异步I/O
1. 为什么要异步I/O (1)用户体验上: 并发的优势: M+N+... -> max(M,N,...) --> 使后端能够快速的响应资源 *并发的劣势:... (2)资源分配: 单线 ...
- (转)C#调用C函数(DLL)传递参数问题
备忘: 1.C函数参数为字符串char*.如果是入参,对应C#中string或StringBuilder:如果是出参对应C#中StringBuider: 2.C函数参数为结构体指针,需在C#中对应定义 ...
- 防止XSS攻击的方式
主要有三种请求方式,进行过滤替换非法符号 1.普通的GET请求数据: 2.FORM表单提交数据: 3.Json格式数据提交: 把下面5个文件放入项目中即可 package com.joppay.adm ...
- LeetCode——Find Duplicate Subtrees
Question Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, yo ...
- Graph_Master(连通分量_C_Trajan缩点+最小路径覆盖)
hdu_3861 题目大意:给定一张有向图,若<u,v>可达(u可以走到v,或者 v可以走到u),则<u,v>需被划分在统一城邦,问最小划分城邦数. 题解:比较裸的题,可以看出 ...
- poj3977 - subset - the second time - 暴力 + 二分
2017-08-26 11:38:42 writer:pprp 已经是第二次写这个题了,但是还是出了很多毛病 先给出AC代码: 解题思路: 之前在培训的时候只是笼统的讲了讲怎么做,进行二分对其中一边进 ...