I'm just starting with Python and I have a big list of subjects and their (BMI) body mass index (along many more data). I need to create a new column (called OMS) where I can state if they're "normal", "overweight", "obese", etcc.
but I just can't find the correct way to do it. I tried np.when but that only works with 2 conditions.
I tried the if, elif, else without success and also the:
df['oms'] = np.nan
df['oms'].loc[(df['IMC'] <=18.5 )] = "slim"
df['oms'].loc[(df['IMC'] >= 18.5) & (df['IMC'] <25 )] = "normal"
df['oms'].loc[(df['IMC'] >= 25) & (df['IMC'] <=30 )] = "overweight"
df['oms'].loc[(df['IMC'] > 30)] = "obese"
any ideas? I'm stuck.