Skip to content
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

BUG: clip_lower/-upper don't accept a sequence starting from 0.12.0 #6966

Closed
immerrr opened this issue Apr 25, 2014 · 3 comments

Comments

Projects
None yet
3 participants
@immerrr
Copy link
Contributor

commented Apr 25, 2014

Here's what I mean:

In [4]: pd.Series(np.arange(7))
Out[4]: 
0    0
1    1
2    2
3    3
4    4
5    5
6    6
dtype: int64

# Let's put some limit on weekends
In [5]: _4.clip_upper([3,3,3,3,3, 4,4])

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-3268c7bee292> in <module>()
----> 1 _4.clip_upper([3,3,3,3,3, 4,4])
/home/dshpektorov/sources/pandas/pandas/core/generic.pyc in clip_upper(self, threshold)
   2636         clipped : same type as input
   2637         """
-> 2638         if isnull(threshold):
   2639             raise ValueError("Cannot use an NA value as a clip threshold")
   2640 

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
@jreback

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2014

thats just a bug,
should be isnull().any()

but can easily do:

In [1]: s = pd.Series(np.arange(7))

In [3]: y = Series([3,3,3,3,3,4,4])

In [5]: s.where(s<y,y)
Out[5]: 
0    0
1    1
2    2
3    3
4    3
5    4
6    4
dtype: int64

@jreback jreback added the Bug label Apr 25, 2014

@jreback jreback added this to the 0.15.0 milestone Apr 25, 2014

@dsm054

This comment has been minimized.

Copy link
Contributor

commented Jun 8, 2014

What's the right idiom for allowing both scalars and vectors to pass here? isnull(3).any() won't work because False doesn't have an any method and calling as(any)array might make a copy we don't want (not actually sure about that). Could do use hasattr, or try/except, or even do an is check on False/True.

Basically, is there already a scalar/vector idiom for this?

@immerrr

This comment has been minimized.

Copy link
Contributor Author

commented Jun 8, 2014

I'd also like to note that pandas's df.any() aggregates across only one axis, while ndarray.any() aggregates the whole array regardless of dimensionality and shapes.

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015

@jreback jreback modified the milestones: 0.16.1, Next Major Release Mar 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.