I have a spark dataframe containing businesses with their contact numbers in 2 columns, however some of my businesses are repeated with different contact info, for example:
| Name: | Phone: |
|---|---|
| bus1 | 082... |
| bus1 | 087... |
| bus2 | 076... |
| bus3 | 081... |
| bus3 | 084... |
| bus3 | 086... |
I want to have 3 lines, 1 for each business with varying phone numbers in each, for example:
| Name: | Phone1: | Phone2: | Phone3: |
|---|---|---|---|
| bus1 | 082... | 087... | |
| bus2 | 076... | ||
| bus3 | 081... | 084... | 086... |
I have tried using select('Name','Phone').distinct(), but I don't know how to pivot it to a single row matching on the 'Name' column... please help