Skip to content

Commit b5b664c

Browse files
committed
TST: Add test for rolling.corr with zero variance
1 parent b864812 commit b5b664c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/test_window.py

+7
Original file line numberDiff line numberDiff line change
@@ -2482,6 +2482,13 @@ def test_rolling_corr_pairwise(self):
24822482
self._check_pairwise_moment('rolling', 'corr', window=10,
24832483
min_periods=5)
24842484

2485+
def test_rolling_corr_with_zero_variance(self):
2486+
# GH 18430
2487+
s = pd.Series(np.zeros(20))
2488+
other = pd.Series(np.arange(20))
2489+
2490+
assert s.rolling(window=5).corr(other=other).isna().all()
2491+
24852492
def _check_pairwise_moment(self, dispatch, name, **kwargs):
24862493
def get_result(obj, obj2=None):
24872494
return getattr(getattr(obj, dispatch)(**kwargs), name)(obj2)

0 commit comments

Comments
 (0)