Skip to content

Commit 6ee04db

Browse files
committed
enforce depr any/all with dt64 in groupby
1 parent c225140 commit 6ee04db

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

pandas/core/arrays/datetimelike.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,12 +1665,7 @@ def _groupby_op(
16651665
raise TypeError(f"datetime64 type does not support {how} operations")
16661666
if how in ["any", "all"]:
16671667
# GH#34479
1668-
warnings.warn(
1669-
f"'{how}' with datetime64 dtypes is deprecated and will raise in a "
1670-
f"future version. Use (obj != pd.Timestamp(0)).{how}() instead.",
1671-
FutureWarning,
1672-
stacklevel=find_stack_level(),
1673-
)
1668+
raise TypeError(f"'{how}' with datetime64 dtypes is not supported")
16741669

16751670
elif isinstance(dtype, PeriodDtype):
16761671
# Adding/multiplying Periods is not valid

pandas/tests/extension/test_datetime.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ def _supports_reduction(self, obj, op_name: str) -> bool:
104104
@pytest.mark.parametrize("skipna", [True, False])
105105
def test_reduce_series_boolean(self, data, all_boolean_reductions, skipna):
106106
meth = all_boolean_reductions
107-
msg = f"'{meth}' with datetime64 dtypes is deprecated and will raise in"
108-
with tm.assert_produces_warning(
109-
FutureWarning, match=msg, check_stacklevel=False
110-
):
107+
msg = f"'{meth}' with datetime64 dtypes is not supported"
108+
with pytest.raises(TypeError, match=msg):
111109
super().test_reduce_series_boolean(data, all_boolean_reductions, skipna)
112110

113111
def test_series_constructor(self, data):

pandas/tests/groupby/test_raises.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ def test_groupby_raises_datetime(
241241
return
242242

243243
klass, msg = {
244-
"all": (None, ""),
245-
"any": (None, ""),
244+
"all": (TypeError, "'all' with datetime64 dtypes is not supported"),
245+
"any": (TypeError, "'any' with datetime64 dtypes is not supported"),
246246
"bfill": (None, ""),
247247
"corrwith": (TypeError, "cannot perform __mul__ with this index type"),
248248
"count": (None, ""),
@@ -285,9 +285,7 @@ def test_groupby_raises_datetime(
285285
"var": (TypeError, "datetime64 type does not support var operations"),
286286
}[groupby_func]
287287

288-
if groupby_func in ["any", "all"]:
289-
warn_msg = f"'{groupby_func}' with datetime64 dtypes is deprecated"
290-
elif groupby_func == "fillna":
288+
if groupby_func == "fillna":
291289
kind = "Series" if groupby_series else "DataFrame"
292290
warn_msg = f"{kind}GroupBy.fillna is deprecated"
293291
else:

0 commit comments

Comments
 (0)