Skip to content

Commit 0ed1a13

Browse files
committed
Additional resample tests
1 parent 7371c80 commit 0ed1a13

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pandas/tests/test_resample.py

+28
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,34 @@ def test_aggregate_normal(self):
33683368
assert_frame_equal(expected, dt_result)
33693369
"""
33703370

3371+
@pytest.mark.parametrize('method, unit', [
3372+
('sum', 0),
3373+
('prod', 1),
3374+
])
3375+
def test_resample_entirly_nat_window(self, method, unit):
3376+
s = pd.Series([0] * 2 + [np.nan] * 2,
3377+
index=pd.date_range('2017', periods=4))
3378+
# nan by default
3379+
result = methodcaller(method)(s.resample("2d"))
3380+
expected = pd.Series([0.0, np.nan],
3381+
index=pd.to_datetime(['2017-01-01',
3382+
'2017-01-03']))
3383+
tm.assert_series_equal(result, expected)
3384+
3385+
# min_count=0
3386+
result = methodcaller(method, min_count=0)(s.resample("2d"))
3387+
expected = pd.Series([0.0, unit],
3388+
index=pd.to_datetime(['2017-01-01',
3389+
'2017-01-03']))
3390+
tm.assert_series_equal(result, expected)
3391+
3392+
# min_count=1
3393+
result = methodcaller(method, min_count=1)(s.resample("2d"))
3394+
expected = pd.Series([0.0, np.nan],
3395+
index=pd.to_datetime(['2017-01-01',
3396+
'2017-01-03']))
3397+
tm.assert_series_equal(result, expected)
3398+
33713399
def test_aggregate_with_nat(self):
33723400
# check TimeGrouper's aggregation is identical as normal groupby
33733401

0 commit comments

Comments
 (0)