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 with a list-like threshold with a nan is broken #19992

Closed
jreback opened this issue Mar 5, 2018 · 1 comment
Closed

BUG: clip with a list-like threshold with a nan is broken #19992

jreback opened this issue Mar 5, 2018 · 1 comment

Comments

@jreback
Copy link
Contributor

@jreback jreback commented Mar 5, 2018

xref #19976

.clip is basically a single or double signed where, where there is a nan present we just drop the bound entirely which is not correct. A fix for this would also fix #19976. So [31] should yield [30], however for scalars we ignore the nans, so maybe could do that here.

In [26]: s = pd.Series([1,2,3])

In [27]: s
Out[27]: 
0    1
1    2
2    3
dtype: int64

In [28]: s.where(s>4,4)
Out[28]: 
0    4
1    4
2    4
dtype: int64

In [29]: s.clip(4)
Out[29]: 
0    4
1    4
2    4
dtype: int64

# broken
In [30]: s.where(s>[0,4,np.nan],[0,4,np.nan])
Out[30]: 
0    1.0
1    4.0
2    NaN
dtype: float64

In [31]: s.clip([0,4,np.nan])
Out[31]: 
0    1
1    2
2    3
dtype: int64

# ok
In [2]: s.where(s>[0,4,4],[0,4,4])
Out[2]: 
0    1
1    4
2    4
dtype: int64

In [3]: s.clip([0,4,4])
Out[3]: 
0    1
1    4
2    4
dtype: int64
@jreback
Copy link
Contributor Author

@jreback jreback commented Aug 2, 2018

closed by #21921

@jreback jreback closed this Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant