问题描述
今天在运行以下代码时报错:
df = df.append(res, ignore_index=True)
AttributeError: 'DataFrame' object has no attribute 'append'
解决方案
看网上说这个是由于pandas2.0中append已被弃用。可以将代码改成以下形式:
df = pd.concat([df, pd.DataFrame([res])], ignore_index=True)
参考链接
python - DataFrame object has no attribute append - Stack Overflow