-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DEPR: groupby.grouper #56521
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
DEPR: groupby.grouper #56521
Conversation
doc/source/whatsnew/v2.2.0.rst
Outdated
@@ -472,7 +472,7 @@ Other Deprecations | |||
- Deprecated strings ``H``, ``S``, ``U``, and ``N`` denoting units in :func:`to_timedelta` (:issue:`52536`) | |||
- Deprecated strings ``H``, ``T``, ``S``, ``L``, ``U``, and ``N`` denoting units in :class:`Timedelta` (:issue:`52536`) | |||
- Deprecated strings ``T``, ``S``, ``L``, ``U``, and ``N`` denoting frequencies in :class:`Minute`, :class:`Second`, :class:`Milli`, :class:`Micro`, :class:`Nano` (:issue:`52536`) | |||
- Deprecated the :class:`.BaseGrouper` attributes ``group_keys_seq`` and ``reconstructed_codes``; these will be removed in a future version of pandas (:issue:`56148`) | |||
- Deprecated the :class:`.DataFrameGroupBy.grouper` and :class:`SeriesGroupBy.grouper`; these will be removed in a future version of pandas (:issue:`56521`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either :attr:
or the word "attribute" somewhere in here?
gen = gb.grouper.get_iterator(obj, axis=gb.axis) | ||
msg = "DataFrameGroupBy.grouper is deprecated" | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
gen = gb.grouper.get_iterator(obj, axis=gb.axis) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just change to _grouper?
assert s.groupby(s).grouper.names == ["name"] | ||
msg = "SeriesGroupBy.grouper is deprecated" | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
assert s.groupby(s).grouper.names == ["name"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty much all of these can just change grouper->_grouper i think, as long as there are a couple that test the deprecation
) | ||
with tm.assert_produces_warning(FutureWarning, match=msg): | ||
tm.assert_numpy_array_equal( | ||
gr.grouper.group_info[1], np.array([], dtype=np.dtype(np.intp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if for some reason this doesnt change to _grouper, i have a medium-strong preference for doing as little inside the context as possible, so e.g. gpr = gr.grouper
would go inside the context and the assert_numpy... would go in a separate line
…_gb_grouper � Conflicts: � pandas/tests/groupby/test_groupby.py
Thanks @jbrockmendel - changes made. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge when ready @jbrockmendel
thanks @rhshadrach |
* DEPR: groupby.grouper * DEPR: groupby.grouper * fix whatsnew, tests * Restore test
@rhshadrach one usage of this that I noticed in downstream (seaborn, mwaskom/seaborn#3615, https://github.com/mwaskom/seaborn/blob/a3cb0f1b33551eb25fed1907d0abdd0237fac215/seaborn/categorical.py#L640) is to access the Do we have a good alternative for that? I haven't followed the PR where you are refactoring |
Using
though #55738 will fix this in all cases I know of. An alternative is to perform a reduction and take the index from the result. I recommend
We do not need to deprecate |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Ref: #55738 (comment)
This reverts the deprecation of
grouper.reconstructed_codes
andgrouper.group_keys_seq
from #56149 in favor of deprecating all ofgrouper
.