@@ -273,42 +273,52 @@ def test_resample_quantile(series):
273
273
"_index_factory,_series_name,_index_start,_index_end" , [DATE_RANGE , PERIOD_RANGE ]
274
274
)
275
275
@pytest .mark .parametrize (
276
- "freq, result_data, result_index, result_freq" ,
276
+ "freq, result_name, result_data, result_index, result_freq" ,
277
277
[
278
278
(
279
279
"D" ,
280
+ "dti" ,
280
281
[1.0 ] * 5 + [np .nan ] * 5 ,
281
282
["2005-01-{}" .format (i ) for i in range (1 , 11 )],
282
283
"D" ,
283
284
),
284
285
(
285
286
"D" ,
287
+ "pi" ,
286
288
[1.0 ] * 5 + [np .nan ] * 5 ,
287
289
["2005-01-{}" .format (i ) for i in range (1 , 11 )],
288
290
"D" ,
289
291
),
290
- ("W" , [2.0 , 3.0 , np .nan ], ["2005-01-02" , "2005-01-09" , "2005-01-16" ], "W-SUN" ),
291
292
(
292
293
"W" ,
294
+ "dti" ,
295
+ [2.0 , 3.0 , np .nan ],
296
+ ["2005-01-02" , "2005-01-09" , "2005-01-16" ],
297
+ "W-SUN" ,
298
+ ),
299
+ (
300
+ "W" ,
301
+ "pi" ,
293
302
[2.0 , 3.0 , np .nan ],
294
303
["2004-12-27/2005-01-02" , "2005-01-03/2005-01-09" , "2005-01-10/2005-01-16" ],
295
304
"W-SUN" ,
296
305
),
297
- ("M" , [5.0 ], ["2005-01-31" ], "M" ),
298
- ("M" , [5.0 ], ["2005-01" ], "M" ),
306
+ ("M" , "dti" , [5.0 ], ["2005-01-31" ], "M" ),
307
+ ("M" , "pi" , [5.0 ], ["2005-01" ], "M" ),
299
308
],
300
309
)
301
- def test_resample_sum (series , freq , result_data , result_index , result_freq ):
310
+ def test_resample_sum (
311
+ series , freq , result_name , result_data , result_index , result_freq
312
+ ):
302
313
# GH 19974
303
314
series [:5 ] = 1
304
315
series [5 :] = np .nan
305
316
result = series .resample (freq ).sum (min_count = 1 )
306
317
307
- result_name = result .name
308
- if isinstance (series .index , DatetimeIndex ) and result_name == "dti" :
309
- index = DatetimeIndex (result_index , freq = result_freq )
310
- elif isinstance (series .index , PeriodIndex ) and result_name == "pi" :
318
+ if isinstance (series .index , PeriodIndex ) and result_name == "pi" :
311
319
index = PeriodIndex (result_index , freq = result_freq )
320
+ elif isinstance (series .index , DatetimeIndex ) and result_name == "dti" :
321
+ index = DatetimeIndex (result_index , freq = result_freq )
312
322
else :
313
323
pytest .skip ("unsupported configuration" )
314
324
0 commit comments