@@ -469,42 +469,3 @@ function row_group_slots!(cols::NTuple{N, AbstractVector},
469469 end
470470 return ngroups, UInt[], Int[], sort
471471end
472-
473-
474- # Return a 3-tuple of a permutation that sorts rows into groups,
475- # and the positions of the first and last rows in each group in that permutation
476- # `groups` must contain group indices in 0:ngroups
477- # Rows with group index 0 are skipped (used when skipmissing=true)
478- # Partly uses the code of Wes McKinney's groupsort_indexer in pandas (file: src/groupby.pyx).
479- function compute_indices (groups:: AbstractVector{<:Integer} , ngroups:: Integer )
480- # count elements in each group
481- stops = zeros (Int, ngroups+ 1 )
482- @inbounds for gix in groups
483- stops[gix+ 1 ] += 1
484- end
485-
486- # group start positions in a sorted table
487- starts = Vector {Int} (undef, ngroups+ 1 )
488- if length (starts) > 0
489- starts[1 ] = 1
490- @inbounds for i in 1 : ngroups
491- starts[i+ 1 ] = starts[i] + stops[i]
492- end
493- end
494-
495- # define row permutation that sorts them into groups
496- rperm = Vector {Int} (undef, length (groups))
497- copyto! (stops, starts)
498- @inbounds for (i, gix) in enumerate (groups)
499- rperm[stops[gix+ 1 ]] = i
500- stops[gix+ 1 ] += 1
501- end
502- stops .- = 1
503-
504- # When skipmissing=true was used, group 0 corresponds to missings to drop
505- # Otherwise it's empty
506- popfirst! (starts)
507- popfirst! (stops)
508-
509- return rperm, starts, stops
510- end
0 commit comments