Skip to content

Commit f7a6c21

Browse files
committed
add tests for period/datetime resample sum with min_count
1 parent 6d11aa8 commit f7a6c21

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pandas/tests/resample/test_datetime_index.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,20 @@ def test_resample_timestamp_to_period(simple_date_range_series):
694694
tm.assert_series_equal(result, expected)
695695

696696

697+
def test_datetime_resample_sum_min_count():
698+
# GH 19974
699+
index = date_range(start="2018", freq="M", periods=6)
700+
data = np.ones(6)
701+
data[3:6] = np.nan
702+
datetime = Series(data, index)
703+
result = datetime.resample("Q").sum(min_count=1)
704+
705+
index = date_range("2018-03-31", "2018-06-30", freq="Q-DEC")
706+
expected = Series([3, np.nan], index)
707+
708+
tm.assert_series_equal(result, expected)
709+
710+
697711
def test_ohlc_5min():
698712
def _ohlc(group):
699713
if isna(group).all():

pandas/tests/resample/test_period_index.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,19 @@ def test_quarterly_resampling(self):
548548
exp = ts.to_timestamp().resample("A").mean().to_period()
549549
tm.assert_series_equal(result, exp)
550550

551+
def test_period_resample_sum_min_count(self):
552+
# GH 19974
553+
index = date_range(start="2018", freq="M", periods=6)
554+
data = np.ones(6)
555+
data[3:6] = np.nan
556+
period = Series(data, index).to_period()
557+
result = period.resample("Q").sum(min_count=1)
558+
559+
index = PeriodIndex(["2018Q1", "2018Q2"], freq="Q-DEC")
560+
expected = Series([3, np.nan], index)
561+
562+
tm.assert_series_equal(result, expected)
563+
551564
def test_resample_weekly_bug_1726(self):
552565
# 8/6/12 is a Monday
553566
ind = date_range(start="8/6/2012", end="8/26/2012", freq="D")

0 commit comments

Comments
 (0)