Skip to content

Change Series.clip to work with numpy.clip #272

Closed
@wesm

Description

@wesm

from @bburan

I always find Series.clip() a bit confusing because the order of
arguments are reversed compared with Numpy's clip() method:

Series.clip(self, upper=None, lower=None)
numpy.clip(a, a_min, a_max, out=None)

Also, the following doesn't work well:

x = Series(data=np.random.uniform(size=10))
np.clip(x, 0.4, 0.6)

I think numpy.clip is checking for the existence of the clip() method
on the Series and attempting to pass the arguments to Series.clip().
Since Series.clip() doesn't support the axis argument this approach
fails.  Ideally, I'd prefer to be able to use clip() without having to
check whether the data is a numpy.ndarray or pandas.Series object.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions