-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: enumerate groups #11642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
can you show an example of its utility! also to note that this is really only useful as a |
Note that this is essentially exactly the same information provided by
|
I couldn't think of a clean way to get factorize to handle the same inputs as groupby, though (both the multiple-series case and the mixed column-name/list input.) Might have missed something obvious, of course, as is my wont. But if I needed to write a few lines to get it to work, then those lines would more naturally fit as a groupby method, or so it seemed to me. |
As I went to implement this, I started to wonder if it doesn't make more sense to use
|
that looks reasonable |
Sometimes it's handy to have access to a distinct integer for each group. For example, using the (internal) grouper:
This can be achieved in a number of ways but none of them are particularly elegant, esp. if we're grouping on multiple keys and/or Series. Accordingly, after a brief discussion on gitter, I propose a new method
transform("enumerate")
which returns a Series of integers from 0 to ngroups-1 matching the order the groups will be iterated in. In other words, we'll simply be applying the following map:(Note this is only to shows the desired behaviour, and wouldn't be how it'd be implemented!)
The text was updated successfully, but these errors were encountered: