FutureWarning: save is not part of the public API in Python

Question:

I am using Python to convert Pandas df to .xlsx (in Plotly-Dash app.). All working well so far but with this warning tho:

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

How should I modify the code below in order to keep its functionality and stability in future? Thanks!

 writer = pd.ExcelWriter("File.xlsx", engine = "xlsxwriter")

 workbook  = writer.book

 df.to_excel(writer, sheet_name = 'Sheet', index = False)
  
 writer.save()
Asked By: Mr.Slow

||

Answers:

just replace save with close.

 writer = pd.ExcelWriter("File.xlsx", engine = "xlsxwriter")

 workbook  = writer.book

 df.to_excel(writer, sheet_name = 'Sheet', index = False)
  
 writer.close()
Answered By: Cranchian
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.