Working with dataframe df:
Count
1
2
3
4
5
Want to add second column, that categorizes everything above 3 as '4+' - needed output:
Count | Category
1 1
2 2
3 3
4 4+
5 4+
This is my code:
df['Category'] = df['Count']
df = df.loc[df['Count'] > 3, 'Category'] = '4+'
And I get this error:
AttributeError: 'str' object has no attribute 'loc'