TypeError: pivot_table() got an unexpected keyword argument 'rows'
来源:互联网 发布:幽浮2知乎 编辑:程序博客网 时间:2024/05/21 00:48
利用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 Mtitle $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
阅读全文
1 0
- TypeError: pivot_table() got an unexpected keyword argument 'rows'
- pivot_table() got an unexpected keyword argument 'rows'
- TypeError: __init__() got an unexpected keyword argument ‘maxlength’
- TypeError: __init__() got an unexpected keyword argument ‘maxlength’
- TypeError: __init__() got an unexpected keyword argument ‘maxlength’
- TypeError: concat() got an unexpected keyword argument 'axis'
- 报错TypeError: pool_2d() got an unexpected keyword argument 'ws'
- TypeError: histogram() got an unexpected keyword argument 'new'问题
- TypeError: __init__() got an unexpected keyword argument 'syntax'
- TypeError:__init__() got an unexpected keyword argument 'xxx'
- Django: TypeError topic() got an unexpected keyword argument 'topics_id'
- pip错误:TypeError: parse() got an unexpected keyword argument 'transport_encoding'
- TypeError: exchange_declare() got an unexpected keyword argument 'type'的解决办法
- pip错误:TypeError: parse() got an unexpected keyword argument 'transport_encoding'
- TypeError: __init__() got an unexpected keyword argument 'shape'
- Keras TypeError: run() got an unexpected keyword argument 'class_mode'
- TypeError: __init__() got an unexpected keyword argument 'shape'
- pip错误:TypeError: parse() got an unexpected keyword argument 'transport_encoding'
- Java直接插入排序算法
- 通过ST官方SPL建立STM32FXXX工程
- 树的重心--cf686d Kay and snowflake
- ContentValues和HashTable和HashMap和properties
- opencv 调用 getPerspectiveTransform 函数报错
- TypeError: pivot_table() got an unexpected keyword argument 'rows'
- HDD is Outdated Technology
- unity调用外部的exe
- Confusing Date Format
- idea将maven项目打包成war包的方式,以及使用war包
- 【STL】codeforces 818D Multicolored Cars
- HDU 1848[Fibonacci again and again] 题解
- HDU 3264 Open-air shopping malls
- C# 使用 itextsharp 对pdf文件进行分割的几种方法(1)——按页码拷贝分割