解决DataFrame对象没有’append’属性的AttributeError错误

自然语言处理执行

train_data = pd.DataFrame()…

contents = pd.DataFrame(content)…

再执行train_data = train_data.append(contents[:400])出现错误AttributeError: 'DataFrame' object has no attribute 'append'

估计是pandas版本升级弃用了 老版本'DataFrame'的append方法。由于pandas与众多的第三方软件包捆绑,一般不宜轻易降低其版本号。故采用使用pandas的concat()方法将两个DataFrame对象连接起来:

df3 = pd.concat([df1, df2], ignore_index=True)

 

物联沃分享整理
物联沃-IOTWORD物联网 » 解决DataFrame对象没有’append’属性的AttributeError错误

发表评论