Skip to content

Rolling methods should support lists #2813

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

Closed
mrjbq7 opened this issue Feb 7, 2013 · 3 comments
Closed

Rolling methods should support lists #2813

mrjbq7 opened this issue Feb 7, 2013 · 3 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations Reshaping Concat, Merge/Join, Stack/Unstack, Explode

Comments

@mrjbq7
Copy link

mrjbq7 commented Feb 7, 2013

Looks like the pandas rolling methods only support numpy arrays, while numpy and bottleneck methods also support lists for convenience:

>>> l = [1,2,3,4]

>>> import numpy as np
>>> np.cumsum(l)
array([ 1,  3,  6, 10])

>>> import bottleneck as bn
>>> bn.move_sum(l, 1)
array([ 1.,  2.,  3.,  4.])

>>> import pandas
>>> pandas.rolling_sum(l, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/pandas-0.10.1-py2.7-linux-x86_64.egg/pandas/stats/moments.py", line 507, in f
    time_rule=time_rule, **kwargs)
  File "/usr/lib/python2.7/site-packages/pandas-0.10.1-py2.7-linux-x86_64.egg/pandas/stats/moments.py", line 281, in _rolling_moment
    return_hook, values = _process_data_structure(arg)
  File "/usr/lib/python2.7/site-packages/pandas-0.10.1-py2.7-linux-x86_64.egg/pandas/stats/moments.py", line 325, in _process_data_structure
    if not issubclass(values.dtype.type, float):
AttributeError: 'list' object has no attribute 'dtype'
@ghost
Copy link

ghost commented Mar 20, 2013

pushing to 0.12

@jreback jreback modified the milestones: 0.15.0, 0.14.0 Feb 18, 2014
@jreback jreback modified the milestones: 0.16.0, Someday Jan 26, 2015
@dsm054
Copy link
Contributor

dsm054 commented Jun 10, 2017

Now that we're using the Series.rolling interface and deprecating pd.rolling_*, I'm not sure this fits into the new API.

@jreback
Copy link
Contributor

jreback commented Jun 10, 2017

good point

@jreback jreback closed this as completed Jun 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

3 participants