Skip to content

Instantly share code, notes, and snippets.

@mrjbq7
Created October 24, 2012 18:46
Show Gist options
  • Save mrjbq7/3948013 to your computer and use it in GitHub Desktop.
Save mrjbq7/3948013 to your computer and use it in GitHub Desktop.
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