I’m looking to add a column to my DataFrame combo2 that represents the ranking of DK_points by each Pos (position) group with the following code.
sort!(combo2, [:Pos, :DK_points], rev=[true, true]) dk_rank =  for pos in groupby(combo2, :Pos) append!(dk_rank, 1:size(pos, 1)) end insertcols!(combo2, 6, DK_rank=dk_rank)
However, one particular value for Pos, “QB”, gives unusual results with the ranking starting at 14 rather than the desired 1.
by(combo2, :Pos, y->DataFrame(minRank = minimum(y[:,:DK_rank])))
Pos minRank String Int64 1 QB 14 2 RB 1 3 WR 1 4 TE 1 5 DST 1
Very confused why this would happen.
Also, wondering if there are better ways to accomplish adding a ranking for multiple columns in a data set by each group of another particular column.