I have a large number of DataFrames with similar prefix df_
, that look like:
df_1
df_x
df_ab
.
.
.
df_1a
df_2b
Of course I can do final_df = pd.concat([df_1, df_x, df_ab, ... df_1a, df_2b], axis = 1)
The issue is that although the prefix df_
will always be there, the rest of the dataframes' names keep changing and do not have any pattern. So, I have to constantly update the list of dataframes in pd.concat
to create the 'final_df`, which is cumbersome.
Question: is there anyway to tell python to concatenate all defined dataframes in the namespace (only) starting with df_
and create the final_df
or at least return a list of all such dataframes that I can then manually feed into pd.concat
?