Combining data from multiple excel files with pandas

Ketut Artayasa
Sharing while learning
1 min readMar 6, 2020

--

This story is as myself notes, sometimes needed while working with many files, instead of remembering step by step, I will save short notes here.

Step 1 import all library that needed

import pandas as pd
import numpy as np
import glob

Step 2 create dataframe for saving all data

all_data_df = pd.DataFrame()
for f in glob.glob(“*_segmen.xlsx”):
df = pd.read_excel(f)
all_data_df = all_data_df.append(df,ignore_index=True)

Step 3 Save dataframe to excel files

all_data_df.to_excel("all_segmen.xlsx")

Done.

--

--