I have a dataframe with sales orders and I want to get the count of the orderlines per order in every row:
Order Orderline
1 0
1 1
1 2
2 0
3 0
3 1
What I would like to obtain is
Order Orderline Count
1 0 3
1 1 3
1 2 3
2 0 1
3 0 2
3 1 2
I tried using transform('count')
as I noticed it being used in How to add a new column and fill it up with a specific value depending on another column's series? but that didn't work out. It flattened down my table instead.
Any ideas on how to accomplish this?