Skip to content

Rolling methods should support lists #2813

Closed
@mrjbq7

Description

@mrjbq7

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsNumeric OperationsArithmetic, Comparison, and Logical operationsReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions