@@ -852,6 +852,16 @@ def test_resample_loffset_arg_type(self):
852
852
assert_frame_equal (result_agg , expected )
853
853
assert_frame_equal (result_how , expected )
854
854
855
+ def test_apply_to_empty_series (self ):
856
+ # GH 14313
857
+ series = self .create_series ()[:0 ]
858
+
859
+ for freq in ['M' , 'D' , 'H' ]:
860
+ result = series .resample (freq ).apply (lambda x : 1 )
861
+ expected = series .resample (freq ).apply (np .sum )
862
+
863
+ assert_series_equal (result , expected , check_dtype = False )
864
+
855
865
856
866
class TestDatetimeIndex (Base ):
857
867
_index_factory = lambda x : date_range
@@ -2192,17 +2202,6 @@ def test_resample_datetime_values(self):
2192
2202
res = df ['timestamp' ].resample ('2D' ).first ()
2193
2203
tm .assert_series_equal (res , exp )
2194
2204
2195
- def test_apply_to_empty_series (self ):
2196
- # GH 14313
2197
- series = self .create_series ()[:0 ]
2198
-
2199
- for freq in ['M' , 'D' , 'H' ]:
2200
- result = series .resample (freq ).apply (lambda x : 1 )
2201
- expected = series .resample (freq ).apply (np .sum )
2202
-
2203
- assert result .name == expected .name
2204
- assert_series_equal (result , expected , check_dtype = False )
2205
-
2206
2205
2207
2206
class TestPeriodIndex (Base ):
2208
2207
_index_factory = lambda x : period_range
@@ -2805,6 +2804,14 @@ def test_evenly_divisible_with_no_extra_bins(self):
2805
2804
result = df .resample ('7D' ).sum ()
2806
2805
assert_frame_equal (result , expected )
2807
2806
2807
+ def test_apply_to_empty_series (self ):
2808
+ # GH 14313
2809
+ series = self .create_series ()[:0 ]
2810
+
2811
+ for freq in ['M' , 'D' , 'H' ]:
2812
+ with pytest .raises (TypeError ):
2813
+ series .resample (freq ).apply (lambda x : 1 )
2814
+
2808
2815
2809
2816
class TestTimedeltaIndex (Base ):
2810
2817
_index_factory = lambda x : timedelta_range
0 commit comments