pd.to excel 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: python dataframe to excel

with pd.ExcelWriter('pandas_multiple.xlsx', engine='xlsxwriter') as writer:    
    # Write each dataframe to a different worksheet.
    final_df.to_excel(writer, sheet_name='Sheet1')
    df_unigrams.to_excel(writer, sheet_name='Sheet2')
    df_bigrams.to_excel(writer, sheet_name='Sheet3')