Skip to content

Commit cd07f4b

Browse files
author
y-p
committed
BUG: rolling_corr should pass center=True to it's delegates
1 parent a626014 commit cd07f4b

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pandas/stats/moments.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,11 @@ def rolling_cov(arg1, arg2, window, min_periods=None, freq=None,
166166
window = min(window, len(arg1), len(arg2))
167167

168168
def _get_cov(X, Y):
169-
mean = lambda x: rolling_mean(x, window, min_periods)
170-
count = rolling_count(X + Y, window)
169+
mean = lambda x: rolling_mean(x, window, min_periods,center=center)
170+
count = rolling_count(X + Y, window,center=center)
171171
bias_adj = count / (count - 1)
172172
return (mean(X * Y) - mean(X) * mean(Y)) * bias_adj
173173
rs = _flex_binary_moment(arg1, arg2, _get_cov)
174-
if center:
175-
if isinstance(rs, (Series, DataFrame, Panel)):
176-
rs = rs.shift(-int((window + 1) / 2.))
177-
else:
178-
offset = int((window + 1) / 2.)
179-
rs[:-offset] = rs[offset:]
180-
rs[-offset:] = np.nan
181174
return rs
182175

183176

0 commit comments

Comments
 (0)