@@ -127,20 +127,30 @@ def test_selection(self, freq, kwargs):
127
127
128
128
@pytest .mark .parametrize ("month" , MONTHS )
129
129
@pytest .mark .parametrize ("meth" , ["ffill" , "bfill" ])
130
- @pytest .mark .parametrize ("conv" , ["start" , "end" ])
131
130
@pytest .mark .parametrize (
132
- ("offset" , "period" ), [("D" , "D" ), ("B" , "B" ), ("ME" , "M" ), ("QE" , "Q" )]
131
+ ("offset" , "period" , "conv" ),
132
+ [
133
+ ("D" , "D" , "start" ),
134
+ ("D" , "D" , "end" ),
135
+ ("B" , "B" , "start" ),
136
+ ("B" , "B" , "end" ),
137
+ ("MS" , "M" , "start" ),
138
+ ("ME" , "M" , "end" ),
139
+ ("QS" , "Q" , "start" ),
140
+ ("QE" , "Q" , "end" ),
141
+ ],
133
142
)
134
143
def test_annual_upsample_cases (
135
144
self , offset , period , conv , meth , month , simple_period_range_series
136
145
):
137
146
ts = simple_period_range_series ("1/1/1990" , "12/31/1991" , freq = f"Y-{ month } " )
138
- warn = FutureWarning if period == "B" else None
139
- msg = r"PeriodDtype\[B\] is deprecated"
140
- if warn is None :
141
- msg = "Resampling with a PeriodIndex is deprecated"
142
- warn = FutureWarning
143
- with tm .assert_produces_warning (warn , match = msg ):
147
+
148
+ msg = (
149
+ r"PeriodDtype\[B\] is deprecated"
150
+ if period == "B"
151
+ else "Resampling with a PeriodIndex is deprecated"
152
+ )
153
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
144
154
result = getattr (ts .resample (period , convention = conv ), meth )()
145
155
expected = result .to_timestamp (period , how = conv )
146
156
expected = expected .asfreq (offset , meth ).to_period ()
@@ -217,21 +227,29 @@ def test_annual_upsample2(self):
217
227
tm .assert_series_equal (result , expected )
218
228
219
229
@pytest .mark .parametrize ("month" , MONTHS )
220
- @pytest .mark .parametrize ("convention" , ["start" , "end" ])
221
230
@pytest .mark .parametrize (
222
- ("offset" , "period" ), [("D" , "D" ), ("B" , "B" ), ("ME" , "M" )]
231
+ ("offset" , "period" , "convention" ),
232
+ [
233
+ ("D" , "D" , "start" ),
234
+ ("D" , "D" , "end" ),
235
+ ("B" , "B" , "start" ),
236
+ ("B" , "B" , "end" ),
237
+ ("MS" , "M" , "start" ),
238
+ ("ME" , "M" , "end" ),
239
+ ],
223
240
)
224
241
def test_quarterly_upsample (
225
242
self , month , offset , period , convention , simple_period_range_series
226
243
):
227
244
freq = f"Q-{ month } "
228
245
ts = simple_period_range_series ("1/1/1990" , "12/31/1995" , freq = freq )
229
- warn = FutureWarning if period == "B" else None
230
- msg = r"PeriodDtype\[B\] is deprecated"
231
- if warn is None :
232
- msg = "Resampling with a PeriodIndex is deprecated"
233
- warn = FutureWarning
234
- with tm .assert_produces_warning (warn , match = msg ):
246
+
247
+ msg = (
248
+ r"PeriodDtype\[B\] is deprecated"
249
+ if period == "B"
250
+ else "Resampling with a PeriodIndex is deprecated"
251
+ )
252
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
235
253
result = ts .resample (period , convention = convention ).ffill ()
236
254
expected = result .to_timestamp (period , how = convention )
237
255
expected = expected .asfreq (offset , "ffill" ).to_period ()
@@ -242,12 +260,12 @@ def test_quarterly_upsample(
242
260
def test_monthly_upsample (self , target , convention , simple_period_range_series ):
243
261
ts = simple_period_range_series ("1/1/1990" , "12/31/1995" , freq = "M" )
244
262
245
- warn = None if target == "D" else FutureWarning
246
- msg = r"PeriodDtype\[B\] is deprecated"
247
- if warn is None :
248
- msg = "Resampling with a PeriodIndex is deprecated"
249
- warn = FutureWarning
250
- with tm .assert_produces_warning (warn , match = msg ):
263
+ msg = (
264
+ "Resampling with a PeriodIndex is deprecated"
265
+ if target == "D"
266
+ else r"PeriodDtype\[B\] is deprecated"
267
+ )
268
+ with tm .assert_produces_warning (FutureWarning , match = msg ):
251
269
result = ts .resample (target , convention = convention ).ffill ()
252
270
expected = result .to_timestamp (target , how = convention )
253
271
expected = expected .asfreq (target , "ffill" ).to_period ()
@@ -923,7 +941,7 @@ def test_resample_with_offset_month(self):
923
941
rs = ser .resample ("M" , offset = "3h" )
924
942
result = rs .mean ()
925
943
result = result .to_timestamp ("M" )
926
- expected = ser .to_timestamp ().resample ("ME " , offset = "3h" ).mean ()
944
+ expected = ser .to_timestamp ().resample ("MS " , offset = "3h" ).mean ()
927
945
# TODO: is non-tick the relevant characteristic? (GH 33815)
928
946
expected .index = expected .index ._with_freq (None )
929
947
tm .assert_series_equal (result , expected )
0 commit comments