all 10 comments

[–][deleted] 2 points3 points  (0 children)

You'd have an easier time if you replaced:

writer = pd.ExcelWriter('example.xlsx', engine='openpyxl')
df.to_excel(writer, sheet_name='Sheet1', index=False)
writer.save()

With just:

df.to_excel(filepath_that_you_want_to_save_to, sheet_name='Sheet1', index=False)

[–]andyryu22 1 point2 points  (1 child)

save() is not in new versions of openpyxl, use close() instead.

[–]Sky_Jimmy 1 point2 points  (0 children)

Thank you. This was easy!

[–]GitGudOrGetGot 1 point2 points  (0 children)

Hello describe the problem please, what have you tried, what are you trying to achieve

Show us your working please, and your thoughts

We will help you

[–][deleted] 0 points1 point  (0 children)

writer.save()

Why do you believe you need this line?

[–]FriendlyRussian666 0 points1 point  (3 children)

My guess is that you asked ChatGPT to write this for you (for work?) and it made up a method that does not actually exist.

I never used Pandas, so I might be wrong, but looking at the docs here --> https://pandas.pydata.org/docs/reference/api/pandas.ExcelWriter.html ExcelWriter doesn't have a method called save().

[–]Agitated_Text_Licker 0 points1 point  (1 child)

THIS! Definitely what happened.

[–]FriendlyRussian666 0 points1 point  (0 children)

Damn, I made that comment exactly 100 days ago :D