df.to_csv("output.csv", index=False)

OR

df.to_excel("output.xlsx")
Answer from mujjiga on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › exporting-a-pandas-dataframe-to-an-excel-file
Exporting a Pandas DataFrame to an Excel file - GeeksforGeeks
July 15, 2025 - In this example, a Pandas DataFrame named cars_data is created to store information about different car models, their maximum speeds, and colors. The data is then written to an Excel file named 'CarsData1.xlsx' using the to_excel() function along with an ExcelWriter object, and the file is saved successfully. ... # importing the module import pandas as pd # creating the DataFrame cars_data = pd.DataFrame({'Cars': ['BMW', 'Audi', 'Bugatti', 'Porsche', 'Volkswagen'], 'MaxSpeed': [220, 230, 240, 210, 190], 'Color': ['Black', 'Red', 'Blue', 'Violet', 'White']}) # writing to Excel datatoexcel = pd.ExcelWriter('CarsData1.xlsx') # write DataFrame to excel cars_data.to_excel(datatoexcel) # save the excel datatoexcel.close() print('DataFrame is written to Excel File successfully.')
Discussions

python - how to download or convert dataframe into excel file? - Stack Overflow
trying to convert or download dataframe into excel file with arabic data. But when i run the script the system crash and display the below error: AttributeError: 'NoneType' object has no attribute ' More on stackoverflow.com
🌐 stackoverflow.com
python - django pandas dataframe download as excel file - Stack Overflow
I have a Django app that will be placed in a Docker container. The app prepares data in Dataframe format. I would like to allow the user to download the data to his/her local drive as excel file... More on stackoverflow.com
🌐 stackoverflow.com
I created an Excel Add-in to generate Pandas Dataframes right inside Excel
TL;DR - The addin creates the python code to correctly read the excel file in and construct the dataframe. Instead of messing around with all of the available options in the read_excel method, it does it for you. Particularly handy when the tables are formatted and have merged cells. Nice Job! I always have this problem with excel as soon as any formatting is applied to the data. I usually create a new sheet, remove all formatting and arrange things in simple columns to make it easier to import. That isn't always a good way to do it, particularly if more data is added later on. More on reddit.com
🌐 r/Python
48
906
August 10, 2021
What's the fastest way to export a dataframe to an excel file?
Thanks for all the tips and feedbacks. Based on these, I started looking around the internets thinking that probably i wasnt the first to experience this problem and I was right. I found suggestions that the engine that is used for exporting the excel file matters. I was using the default openpyxl and had to do a pip install xlsxwriter and used this as df.to_excel("export.xlsx", engine='xlsxwriter'). The problem is that upon exporting to excel, pandas chooses an engine based on the extension (xls-> openpyxl, xlsx-> xlsxwriter), but it needs to be installed separately, otherwise it defaults to the other one. Here are my time tests (~70k rows with 50 columns, 17mb worth of data): export to csv: 1 second export to xlsx (xlsxwriter): 40 seconds export to xlsx (openpyxl): 20 minutes This is the one I had before. Just terrible. Csv export still kicks everyone's butt. Thanks u/lowerthansound and u/xelf , have a great day:) More on reddit.com
🌐 r/learnpython
15
6
July 20, 2021
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › DataFrame › to_excel
Python Pandas DataFrame to_excel() - Export to Excel | Vultr Docs
December 25, 2024 - The to_excel() function in Pandas allows for exporting a DataFrame to an Excel file, offering various parameters to customize the export process. Before diving into specific examples and customization, it's essential to grasp the basic usage ...
🌐
JBI Training
jbinternational.co.uk › article › view › 1260
How to Export Data from Pandas to Excel using Python
March 30, 2023 - Pandas provides a flexible and easy-to-use interface for exporting data from tables, also known as DataFrames, to various file formats, including Excel. In this guide, we have explored the steps for exporting data from Pandas to Excel using Python, including customizing export options.
Find elsewhere
🌐
AskPython
askpython.com › home › how to convert pandas dataframe to excel file
How to Convert Pandas DataFrame to Excel file - AskPython
October 31, 2021 - The step by step process is given below: Import Pandas package in your python code/script file. Create a dataframe of the data you wish to export and initialize the DataFrame with values for rows and columns.
🌐
GitHub
gist.github.com › data-henrik › f0f780147a646e34d7720c5982cc46ef
Python snippet to download pandas Data Frame as CSV or Excel from notebook in IBM Watson Studio · GitHub
Python snippet to download pandas Data Frame as CSV or Excel from notebook in IBM Watson Studio - download_from_notebook.py
🌐
Python Basics
pythonbasics.org › home › pandas › write excel with python pandas
Write Excel with Python Pandas - pythonbasics.org
Write Excel with Python Pandas. You can write any data (lists, strings, numbers etc) to Excel, by first converting it into a  and then writing the DataFrame to Excel. To export a Pandas DataFrame as an Excel file (extension: .xlsx, .xls), use the to_excel() method.
🌐
XlsxWriter
xlsxwriter.readthedocs.io › working_with_pandas.html
Working with Pandas and XlsxWriter - Read the Docs
The Pandas documentation on the pandas.DataFrame.to_excel() method. A more detailed tutorial on Using Pandas and XlsxWriter to create Excel charts. The series of articles on the “Practical Business Python” website about Using Pandas and Excel.
🌐
Medium
medium.com › @whyamit101 › saving-dataframe-to-excel-with-to-excel-c18868f330d2
Saving DataFrame to Excel with to_excel() | by why amit | Medium
February 26, 2025 - Similarly, df2.to_excel(writer, sheet_name='Sheet2', index=False): Saves df2 to "Sheet2". This might surprise you: You can keep adding as many DataFrames as you want, just by calling to_excel for each one and specifying a new sheet name each time.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas write to excel with examples
Pandas Write to Excel with Examples - Spark By {Examples}
June 26, 2025 - Use pandas to_excel() function to write a DataFrame to an Excel sheet with extension .xlsx. By default it writes a single DataFrame to an Excel file, you
🌐
Saturn Cloud
saturncloud.io › blog › how-to-export-from-pandas-to-excel-without-row-names-index
How to Export from Pandas to Excel Without Row Names Index | Saturn Cloud Blog
May 1, 2026 - However, if you open the exported ... export data from Pandas to Excel without row names is to modify the to_excel() function by setting the index parameter to False....
🌐
Enterprise DNA
blog.enterprisedna.co › how-to-export-a-pandas-dataframe-to-excel-in-python
Enterprise DNA: We Help Businesses Put Data and AI to Work
Learn data and AI skills on the platform, bring us in on a project, or run a managed Omni Command Centre. 220K+ professionals trained, 1,500+ companies impacted globally.
🌐
GeeksforGeeks
geeksforgeeks.org › python › dataframe-to_excel-method-in-pandas
DataFrame.to_excel() method in Pandas - GeeksforGeeks
December 18, 2025 - Python · import pandas as pd df = pd.DataFrame({"Name": ["A", "B"], "Score": [85, 92]}) df.to_excel("data.xlsx") Output · Output · Explanation: df.to_excel("data.xlsx") saves the DataFrame to an Excel file named data.xlsx in the current directory.
🌐
Microsoft Support
support.microsoft.com › en-us › office › python-in-excel-dataframes-a10495b2-8372-4f0f-9179-32771fe0dc04
Python in Excel DataFrames | Microsoft Support
Output a DataFrame as Excel values to incorporate other Excel-based analytics like charts, Excel formulas, and conditional formatting. Use the Python output menu in the formula bar to control how Python calculations are returned.
🌐
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.pandas › api › pyspark.pandas.DataFrame.to_excel.html
pyspark.pandas.DataFrame.to_excel — PySpark 4.2.0 documentation
>>> df1 = ps.DataFrame([['a', 'b'], ['c', 'd']], ... index=['row 1', 'row 2'], ... columns=['col 1', 'col 2']) >>> df1.to_excel("output.xlsx") ... If you wish to write to more than one sheet in the workbook, it is necessary to specify an ExcelWriter object: >>> with pd.ExcelWriter('output.xlsx') ...
🌐
LabEx
labex.io › questions › how-to-write-pandas-dataframe-to-excel-file-65431
How to Write Pandas DataFrame to Excel in Python | LabEx
July 25, 2024 - In this example, df is the Pandas DataFrame you want to export, and 'output_file.xlsx' is the name of the Excel file you want to create. The index=False parameter is optional, but it's recommended to set it to False if you don't want the row index to be included in the Excel file. ... import pandas as pd # Create a sample DataFrame data = {'Name': ['Alice', 'Bob', 'Charlie', 'David'], 'Age': [25, 30, 35, 40], 'City': ['New York', 'London', 'Paris', 'Tokyo']} df = pd.DataFrame(data) # Write the DataFrame to an Excel file df.to_excel('employee_data.xlsx', index=False)
🌐
Medium
medium.com › @sunilnepali844 › simplifying-file-exports-in-python-with-io-bytesio-and-pandas-eb073d744064
Simplifying File Exports in Python with io.BytesIO and Pandas
July 11, 2024 - Using io.BytesIO() to export a DataFrame to Excel means the file is created and handled entirely in memory, without writing to the disk. This makes the process faster and more secure, as no temporary files are left on the server. It also simplifies the code and easily allows the file to be sent directly to users as a download...