pandas : assign result of groupby to dataframe to a new column,df['size'].loc[df.groupby('adult')['weight'].transform('idxmax')]