Skip to content

Commit f7c1515

Browse files
committed
update test
1 parent 7a425e6 commit f7c1515

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

pandas/tests/resample/test_base.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -273,42 +273,52 @@ def test_resample_quantile(series):
273273
"_index_factory,_series_name,_index_start,_index_end", [DATE_RANGE, PERIOD_RANGE]
274274
)
275275
@pytest.mark.parametrize(
276-
"freq, result_data, result_index, result_freq",
276+
"freq, result_name, result_data, result_index, result_freq",
277277
[
278278
(
279279
"D",
280+
"dti",
280281
[1.0] * 5 + [np.nan] * 5,
281282
["2005-01-{}".format(i) for i in range(1, 11)],
282283
"D",
283284
),
284285
(
285286
"D",
287+
"pi",
286288
[1.0] * 5 + [np.nan] * 5,
287289
["2005-01-{}".format(i) for i in range(1, 11)],
288290
"D",
289291
),
290-
("W", [2.0, 3.0, np.nan], ["2005-01-02", "2005-01-09", "2005-01-16"], "W-SUN"),
291292
(
292293
"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",
293302
[2.0, 3.0, np.nan],
294303
["2004-12-27/2005-01-02", "2005-01-03/2005-01-09", "2005-01-10/2005-01-16"],
295304
"W-SUN",
296305
),
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"),
299308
],
300309
)
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+
):
302313
# GH 19974
303314
series[:5] = 1
304315
series[5:] = np.nan
305316
result = series.resample(freq).sum(min_count=1)
306317

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":
311319
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)
312322
else:
313323
pytest.skip("unsupported configuration")
314324

0 commit comments

Comments
 (0)