Skip to content

Commit aa5b866

Browse files
"DOC #45443 edited the documentation of where/mask functions" (#47626)
* "#45443 edited the documentation of where/mask functions" * Update generic.py * Update generic.py * Update generic.py * Update pandas/core/generic.py Co-authored-by: Matthew Roeschke <[email protected]> * Update generic.py * Update generic.py Co-authored-by: Matthew Roeschke <[email protected]>
1 parent bd4ff39 commit aa5b866

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

pandas/core/generic.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -9614,7 +9614,9 @@ def where(
96149614
The {name} method is an application of the if-then idiom. For each
96159615
element in the calling DataFrame, if ``cond`` is ``{cond}`` the
96169616
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}.
96189620
96199621
The signature for :func:`DataFrame.where` differs from
96209622
:func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to
@@ -9641,6 +9643,23 @@ def where(
96419643
4 NaN
96429644
dtype: float64
96439645
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+
96449663
>>> s.where(s > 1, 10)
96459664
0 10
96469665
1 10

0 commit comments

Comments
 (0)