df is a DataFrame.
grouped_df = df.groupby(['colA', 'colB']) \
.agg(
{
'ratio': {'avg_ratios': 'mean', 'std_ratios': 'std'},
'n_swipes': {'sum_swipes': 'sum'}
}).reset_index()
grouped_df.columns = grouped_df.columns.droplevel(0)
Seems like it drops the not joined rows which are in one database and not in the other