I want to label encode subgroups in a pandas dataframe. Something like this:
| Category | | Name |
| ---------- | | --------- |
| FRUITS | | Apple |
| FRUITS | | Orange |
| FRUITS | | Apple |
| Vegetables | | Onion |
| Vegetables | | Garlic |
| Vegetables | | Garlic |
to
| Category | | Name | | Label |
| ---------- | | ------- | | ----- |
| FRUITS | | Apple | | 1 |
| FRUITS | | Orange | | 2 |
| FRUITS | | Apple | | 1 |
| Vegetables | | Onion | | 1 |
| Vegetables | | Garlic | | 2 |
| Vegetables | | Garlic | | 2 |