Last active
September 22, 2022 22:47
-
-
Save datagy/329adff704eca82ad16e70c6f0a8100d to your computer and use it in GitHub Desktop.
Read Multiple Excel Files at Once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import os | |
| # Create list of files | |
| file_path = '/Desktop/Files/' | |
| files = [os.path.join(file_path, file) for file in os.listdir(file_path)] | |
| # Join DataFrames Using pd.concat() | |
| df = pd.concat([pd.read_excel(file) for file in files], ignore_index=True) | |
| print(df.head()) | |
| # Returns: | |
| # Day Month Year Name Amount | |
| # 0 1 2 2023 Nik 117 | |
| # 1 2 2 2023 Jane 103 | |
| # 2 3 2 2023 Kate 135 | |
| # 3 4 2 2023 Evan 195 | |
| # 4 5 2 2023 Nik 178 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment