Skip to content

API: add level kwarg for Series.any/.all #8302

Closed
@immerrr

Description

@immerrr

It appears that Series' s.any and s.all methods miss level kwargs, unlike their statistical counterparts like s.sum:

In [4]: s = pd.Series([0,1,2], index=[0,0,1])

In [5]: s.sum(level=0)
Out[5]: 
0    1
1    2
dtype: int64

In [6]: s.prod(level=0)
Out[6]: 
0    0
1    2
dtype: int64

In [7]: s.any(level=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-1d8c43752bc9> in <module>()
----> 1 s.any(level=0)

/home/immerrr/sources/pandas/pandas/core/series.pyc in f(self, *args, **kwargs)
     74     @Appender(func.__doc__)
     75     def f(self, *args, **kwargs):
---> 76         result = func(self.values, *args, **kwargs)
     77         if isinstance(result, (pa.Array, Series)) and result.ndim == 0:
     78             # return NumPy type

TypeError: _any() got an unexpected keyword argument 'level'

In [8]: s.all(level=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-bca0491001a6> in <module>()
----> 1 s.all(level=0)

/home/immerrr/sources/pandas/pandas/core/series.pyc in f(self, *args, **kwargs)
     74     @Appender(func.__doc__)
     75     def f(self, *args, **kwargs):
---> 76         result = func(self.values, *args, **kwargs)
     77         if isinstance(result, (pa.Array, Series)) and result.ndim == 0:
     78             # return NumPy type

TypeError: _all() got an unexpected keyword argument 'level'

Frames have those and I think so should series. Maybe, there are more reduction methods that I know not of that also miss those...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions