I want to bin the figures based on different ranges with my own definition.
lambda is easy but what if the condition is more than 2. I used for if but it does not change anything
country = pd.DataFrame({'COUNTRY':['China','JAPAN','KOREA', 'USA', 'UK'],
'POPULATION':[1200,2345,3400,5600,9600],
'ECONOMY':[86212,11862,1000, 8555,12000]})
for x in country.POPULATION:
if x < 2000:
x = 'small'
elif x >2000 and x <=4000:
x='medium'
elif x > 5000 and x <=6000:
x='big'
else:
'huge'
I hope the data can return the 'small', 'medium', etc. according to the range.