How to Solve Python AttributeError: ‘DataFrame’ object has no attribute ‘concat’
解决问题出处:https://researchdatapod.com/how-to-solve-python-attributeerror-dataframe-object-has-no-attribute-concat/#:~:text=AttributeError%20occurs%20in%20a%20Python%20program%20when%20we,are%20handling%20does%20not%20have%20the%20concat%20attribute.
能阅读英文的可以移步以上链接。
中文版:
这个出错的问题在于,DataFrame 根本就没有 concat 这个方法,concat方法是pandas的内置方法。简单点理解就是,“动物”的对象有猴子,“动物”有“飞、跳、跑、游”的方法,但是猴子不是孙悟空它不会飞。
那怎么办?我就是想让它飞??
没关系,可以滴!
先看例子:
import pandas as pdpizza_names = ['margherita', 'pepperoni', 'four cheeses', 'parmigiana', 'hawaiian', 'marinara']is_vegetarian = [True, False, True, True, False, True]df1 = pd.DataFrame(zip(pizza_names, is_vegetarian), columns=['pizza_names', 'is_vegetarian'])df2 = pd.DataFrame({'prices':[7.99, 8.99, 8.99, 9.99, 9.99, 6.99]})print(df1)
print(df2)
首先,我们强行让这个猴子飞:
df3 = df1.concat(columns=df2['prices'], axis=1)print(df3)
很遗憾,它被你摔死了!“AttributeError: 'DataFrame' object has no attribute 'concat'”
都说了它不会飞不会飞!(DataFrame 中没有 concat 方法!)
其实你可能不理解,为什么孙悟空可以飞?因为它有精斗云啊,所以,我们只需要给它精斗云就可以啦。。。
df3 = pd.concat([df1, df2], axis=1)print(df3)print(type(df3))
~~~
明白了吧,pandas就是那个精斗云,厉害的紧!
ps:你可能会好奇,axis参数是干嘛的,0代表横着飞,1代表竖着飞~ 试试不就知道了嘛 ^.^
How to Solve Python AttributeError: ‘DataFrame’ object has no attribute ‘concat’相关推荐
- python pandas AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘
python使用pandas DataFrame.ix的时候 AttributeError: 'DataFrame' object has no attribute 'ix' 在使用进行DataFra ...
- 成功解决AttributeError: ‘DataFrame‘ object has no attribute ‘tolist‘
成功解决AttributeError: 'DataFrame' object has no attribute 'tolist' 目录 解决问题 解决思路 解决方法 解决问题 return objec ...
- 成功解决AttributeError: 'DataFrame' object has no attribute 'tolist'
成功解决AttributeError: 'DataFrame' object has no attribute 'tolist' 目录 解决问题 解决思路 解决方法 解决问题 AttributeErr ...
- 成功解决AttributeError: 'DataFrame' object has no attribute 'reshape'
成功解决AttributeError: 'DataFrame' object has no attribute 'reshape' 目录 解决问题 解决思路 解决方法 解决问题 AttributeEr ...
- 如何解决AttributeError: ‘DataFrame‘ object has no attribute ‘sort‘
源码: data=pd.read_csv(r'C:\Users\13056\Desktop\tips.csv') data.sort('tip') 报错: AttributeError: 'DataF ...
- 成功解决AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘
成功解决AttributeError: 'DataFrame' object has no attribute 'ix' 目录 解决问题 解决思路 解决方法 解决问题 return object.__ ...
- AttributeError: DataFrame object has no attribute dtype
日萌社 人工智能AI:Keras PyTorch MXNet TensorFlow PaddlePaddle 深度学习实战(不定时更新) 报错:AttributeError: 'DataFrame' ...
- Python AttributeError: 'module' object has no attribute 'posseg'
AttributeError: 'module' object has no attribute 'posseg' 遇到问题: 如果 a 是个目录, b 是个 b.py 文件, func 是 b.py ...
- python AttributeError: ‘Colorbar‘ object has no attribute ‘set_clim‘
运行程序显示错误:AttributeError: 'Colorbar' object has no attribute 'set_clim' 解决: 是matplotlib版本过高所致 matplot ...
最新文章
- SSAS使用时间智能解决本年累计、同比、环比【转载】
- PMP-【第11章 项目风险管理】-2021-2-16(220页-251页)
- 在php中插入数据显示在html_PHP中的浮点型数据计算之程序员脱发问题
- 布道微服务_07服务调用追踪
- 类DefaultWsdl 11定义中英文对比API文档
- 基于指定文本的百度地图poi城市检索的使用(思路最重要)
- 在 Excel 内使用 ODBC 消费 SAP ABAP CDS view
- 网络IPC非阻塞和异步I/O
- React Native : 自定义视图
- 调用cryptography密码学API接口计算SHA256/SHA1哈希摘要
- 区块链的概念是由()于2008年提出_区块链,下一个时代的基础设施
- 找个网页游戏插件开发团队
- 宇视NVR录像机密码忘记找回方式.pdf
- c语言对称矩形的判定,八年级数学下册 第19章 矩形、菱形与正方形 19.1.2 矩形的判定教案 (新版)华东师大版...
- python爬虫之bs4解析和xpath解析
- IBM服务器U盘安装CentOS6.8系统
- AI每日小练习之磨砂玻璃质感图标
- Learn to Augment: Joint Data Augmentation and Network Optimizationfor Text Recognition
- 2020年平安浙江APP年度运营报告
- arduino蓝牙通讯代码_在两块Arduino开发板之间实现蓝牙通信
热门文章
- 计算机开源期刊电子和计算机方向的
- 【高等工程数学】南理工研究生课程 突击笔记5 矩阵分解与广义逆矩阵
- PIC12Fxxx芯片读取AD范例
- 几个可以赚钱的调查问卷网站,适合想用手机挣零花钱的你
- 示教器重定位下机器人动作_ABB机器人学习笔记(四)-手动操纵机器人
- 三维CAD的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
- [Linux Audio Driver] Android 10 machine driver probe函数分析
- 网上拍卖系统 /竞拍系统/在线拍卖系统
- 防火墙ACL控制与NAT转换
- 健身房管理系统八大标准——健身房老板必看