I have a simple loop that does not work, I want my loop to return a string in a column if the values of another column are between such and such value
df['column_text'] = 'None'
for x in df['values_column']:
if (0 < x < 9):
df['column_text'].append('0-9')
elif (10 < x < 19):
df['column_text'].append('10-19')
elif (20 < x < 49):
df['column_text'].append('20-49')
elif (50 < x < 99):
df['column_text'].append('50-99')
elif (100 < x < 249):
df['column_text'].append('100-249')
elif (250 < x < 499):
df['column_text'].append('500-1999')
else:
df['column_text'].append('None')
The loop return this error btw : TypeError: cannot concatenate object of type '<class 'str'>'; only Series and DataFrame objs are valid
Thx for any help!