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_min/max fail if window size is larger than input array #1897

Closed
erg opened this issue Sep 11, 2012 · 0 comments
Closed

pandas.rolling_min/max fail if window size is larger than input array #1897

erg opened this issue Sep 11, 2012 · 0 comments
Labels
Milestone

Comments

@erg
Copy link
Contributor

erg commented Sep 11, 2012

This is a regression since July 12.

import pandas
import numpy as np
pandas.rolling_max(np.arange(3), 100, min_periods=1)
pandas.rolling_min(np.arange(3), 100, min_periods=1)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-782732058ee9> in <module>()
----> 1 pandas.rolling_max(np.arange(3), 100, min_periods=1)

/Library/Python/2.7/site-packages/pandas-0.9.0.dev_1e1c922-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in f(arg, window, min_periods, freq, time_rule, **kwargs)
   436             return func(arg, window, minp, **kwds)
   437         return _rolling_moment(arg, window, call_cython, min_periods,
--> 438                                freq=freq, time_rule=time_rule, **kwargs)
   439 
   440     return f

/Library/Python/2.7/site-packages/pandas-0.9.0.dev_1e1c922-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in _rolling_moment(arg, window, func, minp, axis, freq, time_rule, **kwargs)
   252     return_hook, values = _process_data_structure(arg)
   253     # actually calculate the moment. Faster way to do this?
--> 254     result = np.apply_along_axis(calc, axis, values)
   255 
   256     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.9.0.dev_1e1c922-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in <lambda>(x)
   249     """
   250     arg = _conv_timerule(arg, freq, time_rule)
--> 251     calc = lambda x: func(x, window, minp=minp, **kwargs)
   252     return_hook, values = _process_data_structure(arg)
   253     # actually calculate the moment. Faster way to do this?

/Library/Python/2.7/site-packages/pandas-0.9.0.dev_1e1c922-py2.7-macosx-10.8-intel.egg/pandas/stats/moments.pyc in call_cython(arg, window, minp, **kwds)
   434         def call_cython(arg, window, minp, **kwds):
   435             minp = check_minp(minp, window)
--> 436             return func(arg, window, minp, **kwds)
   437         return _rolling_moment(arg, window, call_cython, min_periods,
   438                                freq=freq, time_rule=time_rule, **kwargs)

/Library/Python/2.7/site-packages/pandas-0.9.0.dev_1e1c922-py2.7-macosx-10.8-intel.egg/pandas/lib.so in pandas.lib.roll_max2 (pandas/src/tseries.c:78735)()

ValueError: Invalid window size 100 for len 3 array
erg added a commit to erg/pandas that referenced this issue Sep 11, 2012
@wesm wesm closed this as completed Sep 12, 2012
wesm pushed a commit that referenced this issue Sep 12, 2012
yarikoptic added a commit to neurodebian/pandas that referenced this issue Sep 27, 2012
* commit 'v0.8.1-203-g67121af': (193 commits)
  BUG: DataFrame column formatting issue in length-truncated column close pandas-dev#1906
  BUG: override min/max in DatetimeIndex to function as expected close pandas-dev#1895
  BUG: DataFrame mixed-type arithmetic column-wise, fix DataFrame.diff upcasting->object bug close pandas-dev#1896
  BUG: treat nobs=1 >= min_periods case in rolling_std/variance as 0 trivially. close pandas-dev#1884
  TST: skip to_file test if URLError occurs on some systems
  VB: resolve test name conflict and update make script
  DOC: minor change to build script to help auto build process
  DOC: fixed extlinks in sphinx conf
  TST: oops import in wrong place
  TST: skip test_console_encode if sys.stdin.encoding is None
  TST: unit test for pandas-dev#1902 and default to csv.QUOTE_MINIMAL
  Make it possible to set quoting for to_csv
  ENH: clean up pandas-dev#1691 changes, rls note
  ENH: add more possible bool values to read_csv pandas-dev#1295
  BUG: fix rolling_max/min for small inputs and large windows. Add a check that the min_period <= window size. Fixes pandas-dev#1897.
  Mention Ubuntu for NeuroDebian repository
  BUG: don't clobber color keyword in Series.plot, close pandas-dev#1890
  DOC: add intersphinx mapping for python library, close pandas-dev#1556
  BUG: fix mixed-integer .ix indexing bugs. close#1799
  BUG: unicode sheet name in to_excel pandas-dev#1828
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants