python错误提示:AttributeError: ‘DataFrame‘ object has no attribute ‘append‘

错误提示:
AttributeError: ‘DataFrame’ object has no attribute ‘append’

出现错误的代码:

df_train_log = pd.DataFrame()
df_train_log = df_train_log.append(log_train, ignore_index=True)

原因:
append包在pandas被弃用

解决方法:
将代码改为:

df_train_log = pd.concat([df_train_log, pd.DataFrame([log_train])], ignore_index=True)

猜你喜欢

转载自blog.csdn.net/weixin_43737995/article/details/132015381
今日推荐