I'm trying to bin some housing price categories in order to overlay them on a map to show neighborhood pricing differences.
When I'm putting this logic together to bin the different housing prices, I get a TypeError of:
TypeError: '<' not supported between instances of 'str' and 'int'
Code is below.
level = []
for i in range(0,len(data_process)):
if (data_process['HousingCost'][i] < 150000):
level.append("Low Level Cost")
elif (data_process['HousingCost'][i] >= 150001 and data_process['HousingCost'][i] < 300000):
level.append("Mid-1 Level Cost")
elif (data_process['HousingCost'][i] >= 300001 and data_process['HousingCost'][i] < 450000):
level.append("Mid-2 Level Cost")
elif (data_process['HousingCost'][i] >= 450001 and data_process['HousingCost'][i] < 600000):
level.append("High-1 Level Cost")
else:
level.append("High-2 Level Cost")
data_process['Level_labels'] = level
data_process.head()
I'm unsure why I'm getting this type error as I think I've structured things correctly.
Can I please have some assistance in correcting this TypeError?
Thank you!