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

Project scenario:

读写EXCEL表


Problem Description

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)

Cause Analysis:

Warning translated: Since 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 xls format. Install openpyxl and write xlsx files instead. You can set options in io.excel.xls file. Write "xlwt" to get rid of this warning. While this option is deprecated and also raises warnings, it can be set globally and suppress warnings.


solution:

When saving the excel sheet, save it in .xlsx format instead of .xls format, and there will be no warning

Guess you like

Origin blog.csdn.net/m0_46403007/article/details/124313366