I am trying to add a column in my DataFrame by using the function transform. I need to groupby a couple of categories and then calculate add a new column based on the lagged values of each row. The reason why I need to groupby is that I do not want to take as lagged values observations from other groups and therefore I need the transformation to be within groups.
However, I do not seem to find how transform allows for this.
Thanks a lot,