I need to see if the values in column Deathrate is lower than 9 and return balanced. If isn't return Urgent and put all this in a new column Humanitarian Help. I tried this first:
new = country_data.filter(items=['Country', 'Deathrate']).where(country_data['Deathrate'] > 9)
new = new.dropna()
new
CodePudding user response:
Try this:
import numpy as np
country_data['Humanitarian Help'] = np.where(country_data['Deathrate'] < 9, "balanced", "Deathrate")
Note that I changed > (greater than) to < (less than) per "Deathrate is lower than 9"
