I have a set of customers that are eligible for a certain type of products:
| Customer | Product |
|---|---|
| John | Banana |
| John | Apple |
| John | Orange |
| Carla | Banana |
| Carla | Apple |
| Carla | Orange |
I also have a model which tells me which products are most suited for the customer, based on his preferences:
| Customer | Most Suited Product | Second Most Suited Product | Third Most Suited Product |
|---|---|---|---|
| John | Peach | Orange | Banana |
| Carla | Apple | Banana | Peach |
As you can see, there may be other products most suited, but they aren't eligible at the moment.
I'm running a campaign and I can only advertise two products per customer. This is down through an outbound sales team which requires me to have duplicates on my dataset.
How would I rank them according to their product most suited in order to have only two rows per customer?
I want this:
| Customer | Product | Rank |
|---|---|---|
| John | Orange | 1 |
| John | Banana | 2 |
| Carla | Apple | 1 |
| Carla | Banana | 2 |
I haven't tried anything yet.
You can do something like this: