Skip to content

Instantly share code, notes, and snippets.

@mrjbq7

mrjbq7/data.npy

Created Oct 24, 2012
Embed
What would you like to do?
pandas bug: rolling_sum and rolling_mean
import numpy as np
import pandas
data = np.load('data.npy')
assert all(data >= 0)
sums = pandas.rolling_sum(data, 2, min_periods=1)
zero = np.where(sums < 0)[0]
assert len(zero) == 0, zero
mean = pandas.rolling_mean(data, 2, min_periods=1)
zero = np.where(mean < 0)[0]
assert len(zero) == 0, zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment