I have the following table
| Path ID | Lane ID | Customer | Source | Destination | Mode |
|---|---|---|---|---|---|
| 1 | 1 | Mumbai | Chicago | Berlin | Ship |
| 1 | 2 | Mumbai | Berlin | Mumbai | Air |
| 2 | 1 | Mumbai | Chicago | Berlin | Air |
| 2 | 2 | Mumbai | Berlin | Dubai | Air |
| 2 | 3 | Mumbai | Dubai | Mumbai | Ship |
I want the following table
| Path ID | Source | Site2 | Site3 | Destination | Lane1 Mode | Lane2 Mode | Lane3 Mode |
|---|---|---|---|---|---|---|---|
| 1 | Chicago | Berlin | Mumbai | Ship | Air | ||
| 2 | Chicago | Berlin | Dubai | Mumbai | Air | Air | Ship |
How do I go about getting this table? I feel like groupby is obviously required but what after that? Not sure how to proceed from there. The dataset is really big so it also needs to be efficient. Any pointers would help :)