Closed
Description
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