Skip to content

Commit 54c5068

Browse files
committed
DOC pandas-dev#45443 edited the documentation of where/mask functions
1 parent 2141c1c commit 54c5068

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

pandas/core/generic.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -9614,7 +9614,8 @@ 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 `cond` {klass} is less in size than `other`, the default bool
9618+
for the missing value is {cond_rev}.
96189619
96199620
The signature for :func:`DataFrame.where` differs from
96209621
:func:`numpy.where`. Roughly ``df1.where(m, df2)`` is equivalent to
@@ -9641,6 +9642,23 @@ def where(
96419642
4 NaN
96429643
dtype: float64
96439644
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+
96449662
>>> s.where(s > 1, 10)
96459663
0 10
96469664
1 10

0 commit comments

Comments
 (0)