Generation

generate functionMon, 13 Feb 2023

Modify the formula below so that it rounds to the nearest integer: df2['respiratory_rate'] = df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform('median'))

def round_up(x): if x - math.floor(x) < 0.5: return math.floor(x) return math.ceil(x) df2['respiratory_rate'] = df2['respiratory_rate'].fillna( df2.groupby('pulse')['respiratory_rate'].transform(round_up))

Questions about programming?Chat with your personal AI assistant