-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
DEPR: Change default to observed=True
in DataFrame.groupby
#43999
Comments
DataFrame.groupby
observed=True
in DataFrame.groupby
pls search the tracker this is a duplicate request |
Sorry, I completely missed it! And I still seem unable to find it no matter what synonyms I try, would you mind sending a link if you have one handy? |
An alternative suggestion could be to that the observed was determined at runtime by default. So if there will be created more groups than lets say 100,000,000 if groups are created in the Cartesian way, then we automatically change to |
observed=True
in DataFrame.groupby
observed=True
in DataFrame.groupby
I think we should pursue this deprecation. By defaulting to |
+1 😄 . In addition, I had some arguments in #43999 on this. I think this is quite a big ergonomic problem, e.g. beginners who don't know |
+1 on deprecating the default, see also #30552 |
Is your feature request related to a problem?
The default behaviour of
pandas.DataFrame.groupby
is currently different depending on the type of the groupers (when one of the groupers is categorical, unobserved categories are added to the groupby by default. This behaviour can be overriden by setting theobserved
argument toFalse
).I feel like making the groupby API consistent by default and regardless of the underlying data type would provide a much better user experience.
Describe the solution you'd like
Default to
observed=False
inpandas.DataFrame.groupby
.API breaking implications
Would break backwards-compatibility.
Describe alternatives you've considered
So far the only option I can think of is to add
observed=True
to every groupby I write to make sure it will behave correctly no matter what kind of data gets passed to it.The text was updated successfully, but these errors were encountered: