python pandas ExcelWriter FutureWarning: save is not part of the public API

升级了Python 到3.10,然后pandas写的ExcelWriter也跟着升级了,以下是版本:

pandas=1.5.0

xlwt==1.3.0

然后是执行原来的导数据到Excel的代码报错警告:

 FutureWarning: save is not part of the public API, usage can give in unexpected results and will be removed in a future version
 

writer = pd.ExcelWriter("excel_path.xlsx")
..... 
writer.save()

解决办法:

升级之后,writer.save()接口已经私有化,调用close()即可。

writer = pd.ExcelWriter("excel_path.xlsx")
#..... 
#writer.save()
writer.close()

close()接口源码:

查看writer.close()接口,里面源码会调用save()并执行关闭接口。

python pandas ExcelWriter FutureWarning: save is not part of the public API_第1张图片

你可能感兴趣的:(python,python,pandas,ExcelWriter,1024程序员节)