Skip to content

Commit 503f55b

Browse files
committed
followup to pandas-dev#28289
1 parent aa4bd7d commit 503f55b

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

pandas/tests/reductions/test_reductions.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,6 @@ def test_timedelta_ops(self):
299299
result = td.to_frame().std()
300300
assert result[0] == expected
301301

302-
# invalid ops
303-
for op in ["skew", "kurt", "sem", "prod", "var"]:
304-
msg = "reduction operation '{}' not allowed for this dtype"
305-
with pytest.raises(TypeError, match=msg.format(op)):
306-
getattr(td, op)()
307-
308-
with pytest.raises(TypeError, match=msg.format(op)):
309-
getattr(td.to_frame(), op)(numeric_only=False)
310-
311302
# GH#10040
312303
# make sure NaT is properly handled by median()
313304
s = Series([Timestamp("2015-02-03"), Timestamp("2015-02-07")])
@@ -318,6 +309,22 @@ def test_timedelta_ops(self):
318309
)
319310
assert s.diff().median() == timedelta(days=6)
320311

312+
@pytest.mark.parametrize("opname", ["skew", "kurt", "sem", "prod", "var"])
313+
def test_invalid_td64_reductions(self, opname):
314+
s = Series(
315+
[Timestamp("20130101") + timedelta(seconds=i * i) for i in range(10)]
316+
)
317+
td = s.diff()
318+
319+
msg = "reduction operation '{op}' not allowed for this dtype"
320+
msg = msg.format(op=opname)
321+
322+
with pytest.raises(TypeError, match=msg):
323+
getattr(td, opname)()
324+
325+
with pytest.raises(TypeError, match=msg):
326+
getattr(td.to_frame(), opname)(numeric_only=False)
327+
321328
def test_minmax_tz(self, tz_naive_fixture):
322329
tz = tz_naive_fixture
323330
# monotonic

0 commit comments

Comments
 (0)