Skip to content

Commit e6091f5

Browse files
authored
TST: Add regression test for groupby rolling (#44774)
1 parent 5da1b24 commit e6091f5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pandas/tests/window/test_groupby.py

+27
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,33 @@ def test_as_index_false(self, by, expected_data):
838838
)
839839
tm.assert_frame_equal(result, expected)
840840

841+
def test_nan_and_zero_endpoints(self):
842+
# https://github.com/twosigma/pandas/issues/53
843+
size = 1000
844+
idx = np.repeat(0, size)
845+
idx[-1] = 1
846+
847+
val = 5e25
848+
arr = np.repeat(val, size)
849+
arr[0] = np.nan
850+
arr[-1] = 0
851+
852+
df = DataFrame(
853+
{
854+
"index": idx,
855+
"adl2": arr,
856+
}
857+
).set_index("index")
858+
result = df.groupby("index")["adl2"].rolling(window=10, min_periods=1).mean()
859+
expected = Series(
860+
arr,
861+
name="adl2",
862+
index=MultiIndex.from_arrays(
863+
[[0] * 999 + [1], [0] * 999 + [1]], names=["index", "index"]
864+
),
865+
)
866+
tm.assert_series_equal(result, expected)
867+
841868

842869
class TestExpanding:
843870
def setup_method(self):

0 commit comments

Comments
 (0)