Skip to content

Rolling.apply documentation not clear #25656

Closed
@js3711

Description

@js3711

The current documentation for rolling.apply states:

func : function
Must produce a single value from an ndarray input if raw=True or a Series if raw=False.

This makes it sound like a series consisting of multiple values can be returned by the apply func. This is not true. The following error results:

Pandas v 0.24.1

samples = roll.apply(lambda x: pd.Series([1]), raw=True)
example = pd.Series(np.random.rand(10000,))
example.rolling(100).apply(lambda x: pd.Series([1,2,3,4]), raw=False)

~/anaconda3/envs/pandas/core/series.py in wrapper(self)
     91             return converter(self.iloc[0])
     92         raise TypeError("cannot convert the series to "
---> 93                         "{0}".format(str(converter)))
     94 
     95     wrapper.__name__ = "__{name}__".format(name=converter.__name__)
TypeError: cannot convert the series to <class 'float'>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions