Skip to content

Commit 603f499

Browse files
committed
Test centered rolling window with offset (pandas-dev#42753).
1 parent b8d750f commit 603f499

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/window/test_rolling.py

+14
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,20 @@ def test_datetimelike_centered_selections(
219219

220220
tm.assert_frame_equal(result, expected, check_dtype=False)
221221

222+
@pytest.mark.parametrize("closed", ["right", "both", "left", "neither"])
223+
def test_datetimelike_centered_offset_covers_all(
224+
closed):
225+
# GH 42753
226+
227+
window = '3s'
228+
index=[Timestamp("20130101 09:00:01"), Timestamp("20130101 09:00:02")]
229+
df = DataFrame({"x": 1}, index=index)
230+
231+
result = df.rolling(window, closed=closed, center=True).sum()
232+
233+
expected = DataFrame({"x": [2.0, 2.0]}, index=index)
234+
235+
tm.assert_frame_equal(result, expected, check_dtype=False)
222236

223237
def test_even_number_window_alignment():
224238
# see discussion in GH 38780

0 commit comments

Comments
 (0)