Combine Multiple Excel Worksheets Into a Single Pandas Dataframe

Prerequisites: Working with excel files using Pandas

In these articles, we will discuss how to Import multiple excel sheet into a single DataFrame and save into a new excel file. Let’s suppose we have two Excel files with the same structure (Excel_1.xlsx, Excel_2.xlsx), then merge both of the sheets into a new Excel file.

 Approach :

  • Import-Module
  • Read Excel file and store into a DataFrame
  • Concat both DataFrame into a new DataFrame
  • Export DataFrame into an Excel File with DataFrame.to_excel() function

Below is the implementation.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# import module
import pandas as pd
  
# Read excel file
# and store into a DataFrame
df1 = pd.read_excel('excel_work\sample_data\Book_1.xlsx')
df2 = pd.read_excel('excel_work\sample_data\Book_2.xlsx')
  
# concat both DataFrame into a single DataFrame
df = pd.concat([df1, df2])
  
# Export Dataframe into Excel file
df.to_excel('final_output.xlsx', index=False)

chevron_right


Output :

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.