Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas.rolling_apply: "Out of bounds on buffer access" #1850

Closed
mrjbq7 opened this issue Sep 6, 2012 · 1 comment
Closed

pandas.rolling_apply: "Out of bounds on buffer access" #1850

mrjbq7 opened this issue Sep 6, 2012 · 1 comment
Labels
Milestone

Comments

@mrjbq7
Copy link

mrjbq7 commented Sep 6, 2012

Looks like pandas.rolling_apply doesn't like a window larger than the length of the array:

In [3]: import pandas

In [4]: import numpy as np

In [5]: a = np.array(range(4))

In [6]: pandas.rolling_sum(a, 10)
Out[6]: array([ nan,  nan,  nan,  nan])

In [7]: pandas.rolling_apply(a, 10, np.sum)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-7-1ff0414da8bd> in <module>()
----> 1 pandas.rolling_apply(a, 10, np.sum)

/Library/Python/2.7/site-packages/pandas-0.8.1-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in rolling_apply(arg, window, func, min_periods, freq, time_rule)
    465         return lib.roll_generic(arg, window, minp, func)
    466     return _rolling_moment(arg, window, call_cython, min_periods,
--> 467                            freq=freq, time_rule=time_rule)

/Library/Python/2.7/site-packages/pandas-0.8.1-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in _rolling_moment(arg, window, func, minp, axis, freq, time_rule, **kwargs)
    227     return_hook, values = _process_data_structure(arg)
    228     # actually calculate the moment. Faster way to do this?
--> 229     result = np.apply_along_axis(calc, axis, values)
    230 
    231     return return_hook(result)

/Library/Python/2.7/site-packages/numpy-1.6.2-py2.7-macosx-10.8-intel.egg/numpy/lib/shape_base.pyc in apply_along_axis(func1d, axis, arr, *args)
     78     outshape = asarray(arr.shape).take(indlist)
     79     i.put(indlist, ind)
---> 80     res = func1d(arr[tuple(i.tolist())],*args)
     81     #  if res is a number, then we have a smaller output array
     82     if isscalar(res):

/Library/Python/2.7/site-packages/pandas-0.8.1-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in <lambda>(x)
    224     """
    225     arg = _conv_timerule(arg, freq, time_rule)
--> 226     calc = lambda x: func(x, window, minp=minp, **kwargs)
    227     return_hook, values = _process_data_structure(arg)
    228     # actually calculate the moment. Faster way to do this?

/Library/Python/2.7/site-packages/pandas-0.8.1-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in call_cython(arg, window, minp)
    463     def call_cython(arg, window, minp):
    464         minp = _use_window(minp, window)
--> 465         return lib.roll_generic(arg, window, minp, func)
    466     return _rolling_moment(arg, window, call_cython, min_periods,
    467                            freq=freq, time_rule=time_rule)

/Library/Python/2.7/site-packages/pandas-0.8.1-py2.7-macosx-10.8-intel.egg/pandas/lib.so in pandas.lib.roll_generic (pandas/src/tseries.c:74581)()

IndexError: Out of bounds on buffer access (axis 0)
@wesm wesm closed this as completed in cd9655c Sep 8, 2012
@wesm
Copy link
Member

wesm commented Sep 8, 2012

fixed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants