Skip to content

Commit

Permalink
Additional resample tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAugspurger committed Dec 23, 2017
1 parent 7371c80 commit 0ed1a13
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pandas/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,34 @@ def test_aggregate_normal(self):
assert_frame_equal(expected, dt_result)
"""

@pytest.mark.parametrize('method, unit', [
('sum', 0),
('prod', 1),
])
def test_resample_entirly_nat_window(self, method, unit):
s = pd.Series([0] * 2 + [np.nan] * 2,
index=pd.date_range('2017', periods=4))
# nan by default
result = methodcaller(method)(s.resample("2d"))
expected = pd.Series([0.0, np.nan],
index=pd.to_datetime(['2017-01-01',
'2017-01-03']))
tm.assert_series_equal(result, expected)

# min_count=0
result = methodcaller(method, min_count=0)(s.resample("2d"))
expected = pd.Series([0.0, unit],
index=pd.to_datetime(['2017-01-01',
'2017-01-03']))
tm.assert_series_equal(result, expected)

# min_count=1
result = methodcaller(method, min_count=1)(s.resample("2d"))
expected = pd.Series([0.0, np.nan],
index=pd.to_datetime(['2017-01-01',
'2017-01-03']))
tm.assert_series_equal(result, expected)

def test_aggregate_with_nat(self):
# check TimeGrouper's aggregation is identical as normal groupby

Expand Down

0 comments on commit 0ed1a13

Please sign in to comment.