1616
1717
1818class TestDatetimeLikeStatReductions :
19- @pytest .mark .parametrize ("box" , [Series , pd .Index , pd .array ])
20- def test_dt64_mean (self , tz_naive_fixture , box ):
19+ def test_dt64_mean (self , tz_naive_fixture , index_or_series_or_array ):
2120 tz = tz_naive_fixture
2221
2322 dti = date_range ("2001-01-01" , periods = 11 , tz = tz )
2423 # shuffle so that we are not just working with monotone-increasing
2524 dti = dti .take ([4 , 1 , 3 , 10 , 9 , 7 , 8 , 5 , 0 , 2 , 6 ])
2625 dtarr = dti ._data
2726
28- obj = box (dtarr )
27+ obj = index_or_series_or_array (dtarr )
2928 assert obj .mean () == pd .Timestamp ("2001-01-06" , tz = tz )
3029 assert obj .mean (skipna = False ) == pd .Timestamp ("2001-01-06" , tz = tz )
3130
3231 # dtarr[-2] will be the first date 2001-01-1
3332 dtarr [- 2 ] = pd .NaT
3433
35- obj = box (dtarr )
34+ obj = index_or_series_or_array (dtarr )
3635 assert obj .mean () == pd .Timestamp ("2001-01-06 07:12:00" , tz = tz )
3736 assert obj .mean (skipna = False ) is pd .NaT
3837
39- @pytest .mark .parametrize ("box" , [Series , pd .Index , pd .array ])
4038 @pytest .mark .parametrize ("freq" , ["s" , "h" , "D" , "W" , "B" ])
41- def test_period_mean (self , box , freq ):
39+ def test_period_mean (self , index_or_series_or_array , freq ):
4240 # GH#24757
4341 dti = date_range ("2001-01-01" , periods = 11 )
4442 # shuffle so that we are not just working with monotone-increasing
@@ -48,7 +46,7 @@ def test_period_mean(self, box, freq):
4846 msg = r"PeriodDtype\[B\] is deprecated"
4947 with tm .assert_produces_warning (warn , match = msg ):
5048 parr = dti ._data .to_period (freq )
51- obj = box (parr )
49+ obj = index_or_series_or_array (parr )
5250 with pytest .raises (TypeError , match = "ambiguous" ):
5351 obj .mean ()
5452 with pytest .raises (TypeError , match = "ambiguous" ):
@@ -62,13 +60,12 @@ def test_period_mean(self, box, freq):
6260 with pytest .raises (TypeError , match = "ambiguous" ):
6361 obj .mean (skipna = True )
6462
65- @pytest .mark .parametrize ("box" , [Series , pd .Index , pd .array ])
66- def test_td64_mean (self , box ):
63+ def test_td64_mean (self , index_or_series_or_array ):
6764 m8values = np .array ([0 , 3 , - 2 , - 7 , 1 , 2 , - 1 , 3 , 5 , - 2 , 4 ], "m8[D]" )
6865 tdi = pd .TimedeltaIndex (m8values ).as_unit ("ns" )
6966
7067 tdarr = tdi ._data
71- obj = box (tdarr , copy = False )
68+ obj = index_or_series_or_array (tdarr , copy = False )
7269
7370 result = obj .mean ()
7471 expected = np .array (tdarr ).mean ()
0 commit comments