Skip to content
Advertisement

Make list after groupby in pandas using apply() function

I have this dataframe:

JavaScript

My goal is to keep tracking the values in column2, based on the letters of column1 separated by(:), the output should look like this:

JavaScript

What’s the most pythonic way to do this:

At the moment I’m able to group by the column 1 and I’m trying to use the apply() function, but I do not know how to map and make this list in the new column.

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement