Sorting multiple dataframes all at once in Pandas [closed]

You can dynamically loop through the dataframes and sort:

dfs = (df_tall, df_short, dfm_tall, dfm_short, dfd_tall, dfd_short)
for df in dfs:
    df.sort_values('Country', ascending=True, inplace=True)

To merge them:

from functools import reduce
df = reduce(lambda x, y: pd.merge(x, y, on='Country', how='outer'), dfs)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top