@@ -299,15 +299,6 @@ def test_timedelta_ops(self):
299
299
result = td .to_frame ().std ()
300
300
assert result [0 ] == expected
301
301
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
-
311
302
# GH#10040
312
303
# make sure NaT is properly handled by median()
313
304
s = Series ([Timestamp ("2015-02-03" ), Timestamp ("2015-02-07" )])
@@ -318,6 +309,22 @@ def test_timedelta_ops(self):
318
309
)
319
310
assert s .diff ().median () == timedelta (days = 6 )
320
311
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
+
321
328
def test_minmax_tz (self , tz_naive_fixture ):
322
329
tz = tz_naive_fixture
323
330
# monotonic
0 commit comments