Row number in DataFrames groupby query

Kinda hacky but this works:

transform(groupby(df,:a),"b"=>mean,"b"=> (x->1:length(x)) =>"r")

I just make that column be a 1:n range where n is the number of elements in the group.

1 Like