I have a dataframe df :
| Number | Master |
|---|---|
| 1 | Apple |
| 2 | Orange |
| 3 | Pineapple |
| 4 | Strawberrry |
| 5 | Blueberry |
| 6 | Plums |
| 7 | Cherry |
| 8 | Dragonfruit |
| 9 | Iceapple |
| 10 | Litchie |
This is just a sample df . original dataframe has 10000 rows.
I want to denote Apple,Pineaple,Orange & Strawberry by 1,2,3,4 encoding( which happens to be the fruits with the top 4 value counts in the df) and rest all fruits as one encoding(5). how to achieve this
expected :-
| Number | Master |
|---|---|
| 1 | 1 |
| 2 | 3 |
| 3 | 2 |
| 4 | 4 |
| 5 | 5 |
| 6 | 5 |
| 7 | 5 |
| 8 | 5 |
| 9 | 5 |
| 10 | 5 |