Python Pandas: how to add a totally new column to a data frame inside of a groupby/transform operation
What problems are you running into with apply? It works for this toy example here and the group lengths are different: In [82]: df Out[82]: X Y 0 0 -0.631214 1 0 0.783142 2 0 0.526045 3 1 -1.750058 4 1 1.163868 5 1 1.625538 6 1 0.076105 7 2 0.183492 8 2 0.541400 9 … Read more