How to save csv file on user desktop

Dear friend, I am attempting to save a pandas DataFrame as a CSV file on the user’s desktop. Could you please provide me with the correct code to accomplish this task, whether it be saving the file to the desktop, the documents folder, or the downloads folder? Thank you in advance for your assistance.

df.to_excel(“c:\Downloads\test.xlsx”) did not work

I don’t think you can do that. You can provide a download button so that the user can download it at will.