File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -9614,7 +9614,9 @@ 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 the axis of ``other`` does not align with axis of
9618
+ ``cond`` {klass}, the misaligned index positions will be filled with
9619
+ {cond_rev}.
9618
9620
9619
9621
The signature for :func:`DataFrame.where` differs from
9620
9622
:func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to
@@ -9641,6 +9643,23 @@ def where(
9641
9643
4 NaN
9642
9644
dtype: float64
9643
9645
9646
+ >>> s = pd.Series(range(5))
9647
+ >>> t = pd.Series([True, False])
9648
+ >>> s.where(t, 99)
9649
+ 0 0
9650
+ 1 99
9651
+ 2 99
9652
+ 3 99
9653
+ 4 99
9654
+ dtype: int64
9655
+ >>> s.mask(t, 99)
9656
+ 0 99
9657
+ 1 1
9658
+ 2 99
9659
+ 3 99
9660
+ 4 99
9661
+ dtype: int64
9662
+
9644
9663
>>> s.where(s > 1, 10)
9645
9664
0 10
9646
9665
1 10
You can’t perform that action at this time.
0 commit comments