There is a df_ru Pandas dataframe: date av_temp deviations country year decade 432393 1988-07-01 16.105 0.158 Russia 1988 1980-1990 432429 1991-07-01 16.385 0.243 Russia 1991 1990-2000 432489 1996-07-01 16.032 0.213 Russia 1996 1990-2000 432513 1998-07-01 16.677 0.183 Russia 1998 1990-2000 432525 1999-07-01 16.412 0.228 Russia 1999 1990-2000 432549 2001-07-01 16.539 0.190 Russia 2001 2000-2010 Write a function that 1) create a new dataframe hot_years 2) group data from df_ru by "year" column and take average values in "av_temp" column 3) leave in the hot_years dataframe only those lines where av_temp > 15
def hot_years(df): hot_years=df.groupby('year').mean() hot_years=hot_years.loc[hot_years.av_temp>15] return hot_years hot_years(df_ru)