Skip to content
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 FutureWarning for observed=False to DeprecationWarning #55235

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Bug fixes

Other
~~~~~
-
- Changed the ``FutureWarning`` raised when ``observed=False`` in :meth:`DataFrame.groupby` and :meth:`Series.groupby` to a ``DeprecationWarning`` (:issue:`54970`)
-

.. ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,7 @@ def __init__(
"to True in a future version of pandas. Pass observed=False to "
"retain current behavior or observed=True to adopt the future "
"default and silence this warning.",
FutureWarning,
DeprecationWarning,
stacklevel=find_stack_level(),
)
observed = False
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ def test_groupby_default_depr(cat_columns, keys):
df = DataFrame({"a": [1, 1, 2, 3], "b": [4, 5, 6, 7]})
df[cat_columns] = df[cat_columns].astype("category")
msg = "The default of observed=False is deprecated"
klass = FutureWarning if set(cat_columns) & set(keys) else None
klass = DeprecationWarning if set(cat_columns) & set(keys) else None
with tm.assert_produces_warning(klass, match=msg):
df.groupby(keys)

Expand Down
Loading