Skip to content Skip to sidebar Skip to footer

Combine Dictionary Of Dataframes Into 1 Single Dataframe

I am looking for a solution to put all my dataframes which are in a dictionary into 1 single giant dataframe. I am relatively new to Python so I am unable to understand how to iter

Solution 1:

I think need concat with dict comprehension:

dodf = {f: pd.read_excel(f, sheet_name=None) for f in files}
df = pd.concat([v for k,v in dodf.items()])

Or:

dodf = {f: pd.read_excel(f, sheet_name=None) for f in files}
df = pd.concat([pd.concat(v) for k,v in dodf.items()])

Solution 2:

df_list = [ v for k,v in dodf.items()] 
df = pd.concat(df_list ,axis=1)

does this work? It also depends whether the concat is by columns or by rows...

Post a Comment for "Combine Dictionary Of Dataframes Into 1 Single Dataframe"