Skip to content

Commit 70e9765

Browse files
committed
Add test case for loffset when using count() method
1 parent 22cf50b commit 70e9765

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

pandas/tseries/tests/test_resample.py

+19
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,25 @@ def test_resample_loffset(self):
937937
expected = ser.resample('w-sun', loffset=-bday).last()
938938
self.assertEqual(result.index[0] - bday, expected.index[0])
939939

940+
def test_resample_loffset_count(self):
941+
# GH issue 12725
942+
start_time = '1/1/2000 00:00:00'
943+
rng = date_range(start_time, periods=100, freq='S')
944+
ts = Series(np.random.randn(len(rng)), index=rng)
945+
946+
result = ts.resample('10S', loffset='1s').count()
947+
948+
expected_index = date_range(start_time, periods=10, freq='10S') + timedelta(seconds=1)
949+
expected = pd.Series(10, index=expected_index)
950+
951+
assert_series_equal(result, expected)
952+
953+
# Same issue should apply to .size() since it goes through
954+
# same code path
955+
result = ts.resample('10S', loffset='1s').size()
956+
957+
assert_series_equal(result, expected)
958+
940959
def test_resample_upsample(self):
941960
# from daily
942961
dti = DatetimeIndex(start=datetime(2005, 1, 1),

0 commit comments

Comments
 (0)