nested renamer is not supported pandas
df.groupby(['col']).agg({'func': func}) to df.groupby(['col']).agg(func=func)
Here is what the above code is Doing:
1. groupby(‘col’) – groups the dataframe by the column ‘col’
2. agg({‘func’: func}) – applies the function ‘func’ to the column ‘func’
3. agg(func=func) – applies the function ‘func’ to the column ‘func’