pandas create an excel file code example

Example 1: export a dataframe to excel pandas

#Python, pandas
#To export a pandas dataframe into Excel

df.to_excel(r'Path where you want to store the exported excel file\File Name.xlsx', index = False)

Example 2: import excel file in python pandas

import pandas as pd

df = pd.read_excel (r'Path where the Excel file is stored\File name.xlsx')

Example 3: pandas excelfile

>>> with ExcelWriter('path_to_file.xlsx') as writer:
...     df1.to_excel(writer, sheet_name='Sheet1')
...     df2.to_excel(writer, sheet_name='Sheet2')