-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
I'm not sure whether this is in the documentation somewhere and I missed it, but I am trying to replicate the behavior of pandas rolling function:
.rolling(3, center=True, min_periods=0)
From the minimal example in the docs:
import numpy as np
import numpy_ext as npext
a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
window = 3
npext.rolling_apply(np.sum, window, a, prepend_nans=True)
array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.])
npext.rolling_apply(np.sum, window, a, prepend_nans=False)
array([ 3, 6, 9, 12, 15, 18, 21, 24])
Is there a way to get the result to match this pandas version?
pd.DataFrame(a).rolling(3, center=True, min_periods=0).apply(np.sum).values.flatten()
array([ 1., 3., 6., 9., 12., 15., 18., 21., 24., 17.])
Metadata
Metadata
Assignees
Labels
No labels