网站建设与网站设计哪个好学seo推广的网站和平台有哪些
文章目录
- 写在前面
- 一、问题描述
- 二、解决方法
- 参考链接
写在前面
自己的测试环境:
Ubuntu20.04
一、问题描述
运行开源的python代码的时候,遇到如下问题
AttributeError: 'DataFrame' object has no attribute 'append'

二、解决方法
报错中的DataFrame是在pandas库,但是由于pandas库的更新,2.0版本及以后的版本删除了append()方法删除了,并使用concat()替代了append()方法的功能。
因此有两种解决方法:
方法一:安装旧版本的 pandas库
卸载现有的pandas,
pip uninstall pandas
然后在官网找到小于2.0的版本并安装,这里安装1.5.3版本:
pip install pandas==1.5.3

方法二:将程序中的DataFrame 使用append() 的程序替换为concat()。
将下列程序
df_test = df_test.append(new_row, ignore_index=True)
修改为
df_test = pd.concat([df_test, new_row], ignore_index=True)
参考链接
[1] gpt.
