Generation

generate functionMon, 13 Feb 2023

Modify the formula below so that it rounds to the nearest integer, but not less than 1 and not more than 4: df2['respiratory_rate'] = df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform('median'))

def respiratory_rate_function(x): if x < 1: return 1 elif x > 4: return 4 else: return round(x) df2['respiratory_rate'] = df2['respiratory_rate'].apply(respiratory_rate_function)

Questions about programming?Chat with your personal AI assistant