I have this pyspark dataframe:
Borough, Neighborhood, Count, Row_Number
B, UES, 5, 1
B, MID, 10, 2
B, UWS, 4, 3
BR, EV, 1, 1
BR, WB, 4, 2
BR, MID, 5, 3
I want to transform it into something like this:
Borough, Neighborhood_1, Count_1, Neighborhood_2, Count_2, Neighborhood_3, Count_3
B, UES, 5, MID, 10, UWS, 4
BR, EV, 1, WB, 4, MID, 5
This is what I could come up with:
df.groupBy('Borough').pivot('Neighborhood')
But I keep getting error. Can anyone point out the mistake?