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.ewma doesn't handle empty inputs correctly #1900

Closed
erg opened this issue Sep 12, 2012 · 1 comment
Closed

pandas.ewma doesn't handle empty inputs correctly #1900

erg opened this issue Sep 12, 2012 · 1 comment
Labels
Milestone

Comments

@erg
Copy link
Contributor

erg commented Sep 12, 2012

In [34]: pandas.ewma(np.array([]), 3)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-34-dd4e4b00c97b> in <module>()
----> 1 pandas.ewma(np.array([]), 3)

/usr/lib/python2.7/site-packages/pandas-0.9.0.dev_c32cc6e-py2.7-linux-x86_64.egg/pandas/stats/moments.pyc in ewma(arg, com, span, min_periods, freq, time_rule, adjust)
    307 
    308     return_hook, values = _process_data_structure(arg)
--> 309     output = np.apply_along_axis(_ewma, 0, values)
    310     return return_hook(output)
    311 

/usr/lib/python2.7/site-packages/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):

/usr/lib/python2.7/site-packages/pandas-0.9.0.dev_c32cc6e-py2.7-linux-x86_64.egg/pandas/stats/moments.pyc in _ewma(v)
    301 
    302     def _ewma(v):
--> 303         result = lib.ewma(v, com, int(adjust))
    304         first_index = _first_valid_index(v)
    305         result[first_index : first_index + min_periods] = NaN

/usr/lib/python2.7/site-packages/pandas-0.9.0.dev_c32cc6e-py2.7-linux-x86_64.egg/pandas/lib.so in pandas.lib.ewma (pandas/src/tseries.c:74301)()

IndexError: Out of bounds on buffer access (axis 0)

I think it should output an empty array instead, like rolling_sum.

In [43]: pandas.rolling_sum(np.array([]), 3)
Out[43]: array([], dtype=float64)
@wesm wesm closed this as completed in 68251c2 Sep 17, 2012
@wesm
Copy link
Member

wesm commented Sep 17, 2012

Thanks. fixed in master

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