Generation

generate functionMon, 06 Feb 2023

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 will create a new hot_years dataframe, group the data by the "year" column, average the values in the "av_temp" column, and leave only those lines in the dataframe where av_temp > 15

def hot_years_create(df_ru, min_temp): df_ru_hot = df_ru.groupby(['year'])['av_temp'].mean().reset_index() return df_ru_hot[df_ru_hot['av_temp'] > min_temp] hot_years_create(df_ru, 15)

Questions about programming?Chat with your personal AI assistant