【FutureWarning: As the xlwt package is no longer maintained……】

【FutureWarning: As the xlwt package is no longer maintained……】,第1张

项目场景:

读写EXCEL表


问题描述

D:/pycharm/time_series/gui/SpecialValueProcessingDialog.py:49: FutureWarning: As the xlwt package is no longer maintained, the xlwt engine will be removed in a future version of pandas . This is the only engine in pandas that supports writing in the xls format. Install openpyxl and write to an xlsx file instead. You can set the option io.excel.xls.writer to 'xlwt' to silence this warning. While this option is deprecated and will also raise a warning, it can be globally set and the warning suppressed. data.to_excel(save_file_path)

data = pd.read_excel(open_file_path,sheet_name=0,header=header,index_col=index_col)
print(data.head())
data.replace([-9999,0],np.nan)
data.to_excel(save_file_path)

原因分析:

警告翻译过来:由于xlwt软件包不再维护,xlwt引擎将在未来版本的pandas中删除。这是pandas中唯一支持xls格式写入的引擎。安装openpyxl并改为写入xlsx文件。您可以设置选项io.excel.xls文件。写入“xlwt”以消除此警告。虽然此选项已弃用,并且还会引发警告,但可以全局设置它并抑制警告。


解决方案:

保存excel表时保存为.xlsx格式,而不是.xls格式,就不会有警告

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/718466.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-25
下一篇 2022-04-25

发表评论

登录后才能评论

评论列表(0条)

保存