replicate pandas
ngroup
behavior
#19481
Labels
enhancement
New feature or an improvement of an existing feature
pandas
ngroup
behavior
#19481
Description
Loving
polars
and trying to migrate all of mypandas
code over. This FR would simplify one aspect of my migration.It would be very nice to have functionality like
pandas
'sngroup
method.A couple posts where users are asking how to accomplish this:
https://stackoverflow.com/questions/75483708/replicate-pandas-ngroup-behaviour-in-polars
https://stackoverflow.com/questions/74600568/compute-pandas-n-group-in-polars-and-assign-new-id
To be fair, there already is a viable approach to this, but it is more complicated:
My use case for this is passing
polars
prepped datato_torch()
and then doing essentially group-by sums withtorch.scatter_add
which requires anindex
to sum over: https://pytorch.org/docs/stable/generated/torch.scatter_add.htmlThe text was updated successfully, but these errors were encountered: