I have a dataframe like this
| client | colors |
|---|---|
| Maria | Black |
| Maria | Blue |
| Nadia | Blue |
| Nadia | Black |
| Sophie | Blue |
| Maud | Red |
Each client has one or more colors and I want to create
- an ID_combinaison for each combinaision of colors that exists, for exemple in the table above we have three combinaisions (Black/Blue, Blue, Red) and for each one I want to assigniate a unique ID.
- For each ID_combinaision, the number_clients in it (for example there are 2 clients in the combinaision Black/Blue and in the Blue)
The result would look like this:
| ID_combinaision | colors | number_clients |
|---|---|---|
| 1 | Black | 2 |
| 1 | Blue | 2 |
| 2 | Blue | 1 |
| 3 | Red | 1 |
How can I do this?
Thanks!