@@ -104,13 +104,8 @@ def test_asfreq_fill_value(index):
104104def test_resample_interpolate (index ):
105105 # GH#12925
106106 df = DataFrame (range (len (index )), index = index )
107- warn = None
108- if isinstance (df .index , PeriodIndex ):
109- warn = FutureWarning
110- msg = "Resampling with a PeriodIndex is deprecated"
111- with tm .assert_produces_warning (warn , match = msg ):
112- result = df .resample ("1min" ).asfreq ().interpolate ()
113- expected = df .resample ("1min" ).interpolate ()
107+ result = df .resample ("1min" ).asfreq ().interpolate ()
108+ expected = df .resample ("1min" ).interpolate ()
114109 tm .assert_frame_equal (result , expected )
115110
116111
@@ -199,13 +194,7 @@ def test_resample_empty_series(freq, index, resample_method):
199194 elif freq == "ME" and isinstance (ser .index , PeriodIndex ):
200195 # index is PeriodIndex, so convert to corresponding Period freq
201196 freq = "M"
202-
203- warn = None
204- if isinstance (ser .index , PeriodIndex ):
205- warn = FutureWarning
206- msg = "Resampling with a PeriodIndex is deprecated"
207- with tm .assert_produces_warning (warn , match = msg ):
208- rs = ser .resample (freq )
197+ rs = ser .resample (freq )
209198 result = getattr (rs , resample_method )()
210199
211200 if resample_method == "ohlc" :
@@ -261,9 +250,7 @@ def test_resample_nat_index_series(freq, resample_method):
261250
262251 ser = Series (range (5 ), index = PeriodIndex ([NaT ] * 5 , freq = freq ))
263252
264- msg = "Resampling with a PeriodIndex is deprecated"
265- with tm .assert_produces_warning (FutureWarning , match = msg ):
266- rs = ser .resample (freq )
253+ rs = ser .resample (freq )
267254 result = getattr (rs , resample_method )()
268255
269256 if resample_method == "ohlc" :
@@ -302,13 +289,7 @@ def test_resample_count_empty_series(freq, index, resample_method):
302289 elif freq == "ME" and isinstance (ser .index , PeriodIndex ):
303290 # index is PeriodIndex, so convert to corresponding Period freq
304291 freq = "M"
305-
306- warn = None
307- if isinstance (ser .index , PeriodIndex ):
308- warn = FutureWarning
309- msg = "Resampling with a PeriodIndex is deprecated"
310- with tm .assert_produces_warning (warn , match = msg ):
311- rs = ser .resample (freq )
292+ rs = ser .resample (freq )
312293
313294 result = getattr (rs , resample_method )()
314295
@@ -338,13 +319,7 @@ def test_resample_empty_dataframe(index, freq, resample_method):
338319 elif freq == "ME" and isinstance (df .index , PeriodIndex ):
339320 # index is PeriodIndex, so convert to corresponding Period freq
340321 freq = "M"
341-
342- warn = None
343- if isinstance (df .index , PeriodIndex ):
344- warn = FutureWarning
345- msg = "Resampling with a PeriodIndex is deprecated"
346- with tm .assert_produces_warning (warn , match = msg ):
347- rs = df .resample (freq , group_keys = False )
322+ rs = df .resample (freq , group_keys = False )
348323 result = getattr (rs , resample_method )()
349324 if resample_method == "ohlc" :
350325 # TODO: no tests with len(df.columns) > 0
@@ -386,14 +361,7 @@ def test_resample_count_empty_dataframe(freq, index):
386361 elif freq == "ME" and isinstance (empty_frame_dti .index , PeriodIndex ):
387362 # index is PeriodIndex, so convert to corresponding Period freq
388363 freq = "M"
389-
390- warn = None
391- if isinstance (empty_frame_dti .index , PeriodIndex ):
392- warn = FutureWarning
393- msg = "Resampling with a PeriodIndex is deprecated"
394- with tm .assert_produces_warning (warn , match = msg ):
395- rs = empty_frame_dti .resample (freq )
396- result = rs .count ()
364+ result = empty_frame_dti .resample (freq ).count ()
397365
398366 index = _asfreq_compat (empty_frame_dti .index , freq )
399367
@@ -422,14 +390,7 @@ def test_resample_size_empty_dataframe(freq, index):
422390 elif freq == "ME" and isinstance (empty_frame_dti .index , PeriodIndex ):
423391 # index is PeriodIndex, so convert to corresponding Period freq
424392 freq = "M"
425-
426- msg = "Resampling with a PeriodIndex"
427- warn = None
428- if isinstance (empty_frame_dti .index , PeriodIndex ):
429- warn = FutureWarning
430- with tm .assert_produces_warning (warn , match = msg ):
431- rs = empty_frame_dti .resample (freq )
432- result = rs .size ()
393+ result = empty_frame_dti .resample (freq ).size ()
433394
434395 index = _asfreq_compat (empty_frame_dti .index , freq )
435396
@@ -465,21 +426,12 @@ def test_resample_apply_empty_dataframe(index, freq, method):
465426 ],
466427)
467428@pytest .mark .parametrize ("dtype" , [float , int , object , "datetime64[ns]" ])
468- @pytest .mark .filterwarnings (r"ignore:PeriodDtype\[B\] is deprecated:FutureWarning" )
469429def test_resample_empty_dtypes (index , dtype , resample_method ):
470430 # Empty series were sometimes causing a segfault (for the functions
471431 # with Cython bounds-checking disabled) or an IndexError. We just run
472432 # them to ensure they no longer do. (GH #10228)
473- warn = None
474- if isinstance (index , PeriodIndex ):
475- # GH#53511
476- index = PeriodIndex ([], freq = "B" , name = index .name )
477- warn = FutureWarning
478- msg = "Resampling with a PeriodIndex is deprecated"
479-
480433 empty_series_dti = Series ([], index , dtype )
481- with tm .assert_produces_warning (warn , match = msg ):
482- rs = empty_series_dti .resample ("D" , group_keys = False )
434+ rs = empty_series_dti .resample ("D" , group_keys = False )
483435 try :
484436 getattr (rs , resample_method )()
485437 except DataError :
@@ -512,18 +464,8 @@ def test_apply_to_empty_series(index, freq):
512464 elif freq == "ME" and isinstance (ser .index , PeriodIndex ):
513465 # index is PeriodIndex, so convert to corresponding Period freq
514466 freq = "M"
515-
516- msg = "Resampling with a PeriodIndex"
517- warn = None
518- if isinstance (ser .index , PeriodIndex ):
519- warn = FutureWarning
520-
521- with tm .assert_produces_warning (warn , match = msg ):
522- rs = ser .resample (freq , group_keys = False )
523-
524- result = rs .apply (lambda x : 1 )
525- with tm .assert_produces_warning (warn , match = msg ):
526- expected = ser .resample (freq ).apply ("sum" )
467+ result = ser .resample (freq , group_keys = False ).apply (lambda x : 1 )
468+ expected = ser .resample (freq ).apply ("sum" )
527469
528470 tm .assert_series_equal (result , expected , check_dtype = False )
529471
@@ -541,16 +483,8 @@ def test_resampler_is_iterable(index):
541483 series = Series (range (len (index )), index = index )
542484 freq = "h"
543485 tg = Grouper (freq = freq , convention = "start" )
544- msg = "Resampling with a PeriodIndex"
545- warn = None
546- if isinstance (series .index , PeriodIndex ):
547- warn = FutureWarning
548-
549- with tm .assert_produces_warning (warn , match = msg ):
550- grouped = series .groupby (tg )
551-
552- with tm .assert_produces_warning (warn , match = msg ):
553- resampled = series .resample (freq )
486+ grouped = series .groupby (tg )
487+ resampled = series .resample (freq )
554488 for (rk , rv ), (gk , gv ) in zip (resampled , grouped ):
555489 assert rk == gk
556490 tm .assert_series_equal (rv , gv )
@@ -570,13 +504,8 @@ def test_resample_quantile(index):
570504 q = 0.75
571505 freq = "h"
572506
573- msg = "Resampling with a PeriodIndex"
574- warn = None
575- if isinstance (ser .index , PeriodIndex ):
576- warn = FutureWarning
577- with tm .assert_produces_warning (warn , match = msg ):
578- result = ser .resample (freq ).quantile (q )
579- expected = ser .resample (freq ).agg (lambda x : x .quantile (q )).rename (ser .name )
507+ result = ser .resample (freq ).quantile (q )
508+ expected = ser .resample (freq ).agg (lambda x : x .quantile (q )).rename (ser .name )
580509 tm .assert_series_equal (result , expected )
581510
582511
0 commit comments