我需要查看列Deathrate
中的值是否低于9并返回balanced
。如果不是,则返回Urgent
,并将所有这些放在新列Humanitarian Help
中。我首先尝试了这个:
new = country_data.filter(items=['Country', 'Deathrate']).where(country_data['Deathrate'] > 9)
new = new.dropna()
new
试试这个:
import numpy as np
country_data['Humanitarian Help'] = np.where(country_data['Deathrate'] < 9, "balanced", "Deathrate")
注意,我将CCD_ 5(大于(改变为CCD_;CCD_ 7比9〃低;