Modify the function below so that it rounds to the nearest integer, but not less than 1 and not more than 4: def value_filler(row): filler = df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform('median')) if filler < 1: return 1 elif filler > 4: return 4 else: return df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform('median')) df2['respiratory_rate'] = df2['respiratory_rate'].apply(value_filler)
def value_filler(row): filler = df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform('median')) if filler < 1: return 1 elif filler > 4: return 4 else: return round(df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform('median'))) df2['respiratory_rate'] = df2['respiratory_rate'].apply(value_filler)