I want to combine the rows and separate distinct entries by a comma. I tried the following. Starting from
Postcode Borough Neighbourhood
M3A North York Parkwoods
M3A North York Victoria Village
I typed in the following command
df.groupby(['Postcode','Borough'])["Neighbourhood"].apply(lambda item:', '.join(item)
But that gives me
Neighbourhood
Postcode Borough
M3A North York Parkwoods, Victoria Village
The problem is that the last column is somehow 'above' all the others. Can''t I do this in a way that retains the old column structure? Thanks!