更新到Python3.10后,我现在在使用frame时收到以下警告。将字典附加到数据帧。
FutureWarning: The frame.append method is deprecated and will be
removed from pandas in a future version. Use pandas.concat instead.
下面是代码。这仍然有效,尽管我想解决这个警告。
report = report.append({
"period":period,
"symbol":symbol,
"start_date":start_date,
"start_price":start_price,
"start_market_cap":start_market_cap,
"end_date":end_date,
"end_price":end_price,
"end_market_cap":end_market_cap,
"return":return_
},ignore_index=True)
我已将代码更新为以下内容,这引发了一个不同的警告:
report = pd.concat([report,{
"period":period,
"symbol":symbol,
"start_date":start_date,
"start_price":start_price,
"start_market_cap":start_market_cap,
"end_date":end_date,
"end_price":end_price,
"end_market_cap":end_market_cap,
"return":return_
}],ignore_index=True)
TypeError: cannot concatenate object of type '<class 'dict'>'; only Series and DataFrame objs are valid
2个问题:
第一个警告错了吗?
实现这一目标的3.10方法是什么?
谢谢