File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -9614,7 +9614,8 @@ def where(
9614
9614
The {name} method is an application of the if-then idiom. For each
9615
9615
element in the calling DataFrame, if ``cond`` is ``{cond}`` the
9616
9616
element is used; otherwise the corresponding element from the DataFrame
9617
- ``other`` is used.
9617
+ ``other`` is used. If `cond` {klass} is less in size than `other`, the default bool
9618
+ for the missing value is {cond_rev}.
9618
9619
9619
9620
The signature for :func:`DataFrame.where` differs from
9620
9621
:func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to
@@ -9641,6 +9642,23 @@ def where(
9641
9642
4 NaN
9642
9643
dtype: float64
9643
9644
9645
+ >>> s = pd.Series(range(5))
9646
+ >>> t = pd.Series([True, False])
9647
+ >>> s.where(t,99)
9648
+ 0 0
9649
+ 1 99
9650
+ 2 99
9651
+ 3 99
9652
+ 4 99
9653
+ dtype: int64
9654
+ >>> s.mask(t, 99)
9655
+ 0 99
9656
+ 1 1
9657
+ 2 99
9658
+ 3 99
9659
+ 4 99
9660
+ dtype: int64
9661
+
9644
9662
>>> s.where(s > 1, 10)
9645
9663
0 10
9646
9664
1 10
You can’t perform that action at this time.
0 commit comments