Reputation: 6260
I try to load multiple excel files with multiple excel sheets into a pandas dataframe, right now I am running:
import pandas as pd
import glob
files = glob.glob(r'C:\...\Data\*.xlsx')
dfs = pd.read_excel(f,sheet_name=None) for f in files]
df = pd.concat(dfs, ignore_index=True)
The none parameter makes sure that I load all sheets in every excel, but i get the error:
TypeError: cannot concatenate object of type ', only Series and Dataframe objs are valid.
How can I solve this?
Upvotes: 0
Views: 210
Reputation: 862431
Here is necessary join DataFrame
s in first list comprehension, because if pass sheet_name=None
get Orderdict of DataFrames:
dfs = [pd.concat(pd.read_excel(f,sheet_name=None)) for f in files]
df = pd.concat(dfs, ignore_index=True)
Upvotes: 1