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 dataframe hot_years and leave in it only those lines where av_temp > 12

def filter_hot_years(df, hot_temp = 12, country = 'Russia'): df_hot = df[(df['av_temp'] > hot_temp) & (df['country'] == country)] return df_hot df_hot_years = filter_hot_years(df_ru, hot_temp = 18)

Questions about programming?Chat with your personal AI assistant