1#1. Create a pandas excel writer instance and name the excel file
2xlwriter = pd.ExcelWriter('Customer_Details.xlsx')
3#NB: If you don't include a file path like 'C:\Users\Ron\Desktop\File_Name.xlsx'
4# It will save to your default folder, that is,
5#where the file you're reading from is located.
6
7#2. Write each dataframe to a worksheet with a name
8dfName.to_excel(xlwriter, sheet_name = 'Name', index = False)
9dfAddress.to_excel(xlwriter, sheet_name = 'Address', index = False)
10dfContact.to_excel(xlwriter, sheet_name = 'Contact', index = False)
11
12#3. Close the instance
13xlwriter.close()
1# Create a Pandas Excel writer using XlsxWriter as the engine.
2with pd.ExcelWriter('pandas_multiple.xlsx', engine='xlsxwriter') as writer:
3 # Write each dataframe to a different worksheet.
4 final_df.to_excel(writer, sheet_name='Sheet1')
5 df_unigrams.to_excel(writer, sheet_name='Sheet2')
6 df_bigrams.to_excel(writer, sheet_name='Sheet3')
7