Skip to content
Advertisement

How do you cumulatively aggregate string in pandas?

I have a column that contains strings.

JavaScript

I want to cumulatively aggregate the string through the y-axis.

This is the desired output.

JavaScript

Something like this can be achieved using the expanding or cumsum() function, however it appears to work for numeric attributes only.

Advertisement

Answer

JavaScript

a quick idea

JavaScript

output:

JavaScript

or just:

JavaScript

output:

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