I have a simple DataFrame like the following:
| lead | Rating |
|---|---|
| Clint | 2 |
| Saoro | 1 |
| Clint | 3 |
| Saoro | 4 |
| Clint | 5 |
| Clint | 6 |
| billy | 9 |
| Clint | 10 |
I want to Replace rating column values as 1-3 - low, 4-6 - average, 7-8 - Good, 9-10 - Excellent
I tried with,
df['Rating'].mask(df['Rating'] <=3 ,'low', inplace=True)
df3['Rating'].mask((df3['Rating'] >=4) | (df3['Rating'] < 7) ,'average', inplace=True)
but this will give error " TypeError: '>=' not supported between instances of 'str' and 'int'" as it is taking into consideration the firstly replaced column value "low" also in the second line. Its the same when I tried using lamba function also.