Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/Excel/Excel_Consolidate_files.ipynb
2972 views
Kernel: Python 3

Excel.png

Excel - Consolidate files

Give Feedback | Bug report

Tags: #excel #pandas #read #save #naas #asset #finance #snippet

Last update: 2023-04-12 (Created: 2021-04-14)

Description: This notebook provides a comprehensive guide to consolidating multiple Excel files into one.

Input

Import libraries

import pandas as pd import naas

Variables

# Input excel_file_path1 = "Excel-Sales_Jan2020.xlsx" excel_file_path2 = "Excel-Sales_Jan2020.xlsx" # Output excel_output_path = "Conso.xlsx"

Model

Read the 2 Excel files

You want to add more parameters ?
👉 Check out the pandas documentation here.

df1 = pd.read_excel(excel_file_path1) df1
df2 = pd.read_excel(excel_file_path2) df2

Consolidate Excel

df_concat = pd.concat([df1, df2], axis=0).reset_index(drop=True) df_concat

Output

Save dataframe to Excel

You want to add more parameters ?
👉 Check out the pandas documentation here.

df_concat.to_excel(excel_output_path) print(f'💾 Excel '{excel_output_path}' successfully saved in Naas.')

Share excel with Naas

naas.asset.add(excel_output_path)