The question might be odd, so here's an example.
Suppose my data looks like below:
As you see there are 3 elements a, b, c and we can just groupby & aggregate like:
but what I really want to do is, I want to "SEPERATE" "within" groups.
So the desired result is:
this means that the first sequential 'a' group and the second 'a' that appears later is treated different. Let me show you simply by a list.
The point is we have to consider the sequence. It's not just using pandas cumcount, which only considers the count of appearance. I want to divide each 'sequences', even within same element group.(first aaa and second aaa is different)
I don't think this is that simple in pandas, though I'm avoiding to do this job by just making explicit function-based logic. In short, I want to do this much more simply. Is there any idea?