I want to get the biggest temperature chanche in a dataframe of countries.
My first Idea was to make groups df.groupby(‘country_code’)[‘temperature’].max(), df.groupby(‘country_code’)[‘temperature’].min(), subtract them and get the maximum. I guess there is a better way to to that?
>Solution :
Here’s a slightly different approach, dealing with only one set of groups
def temp_range(group):
return group.max() - group.min()
df.groupby('country_code')['temperature'].apply(temp_range)
Not sure if it’s better though