Skip to content

Commit 6c613c8

Browse files
Daniel SaxtonWillAyd
Daniel Saxton
authored andcommitted
Improve where docstring (pandas-dev#26018)
1 parent a1fee91 commit 6c613c8

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

pandas/core/generic.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -8774,22 +8774,22 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
87748774
.. versionadded:: 0.18.1
87758775
A callable can be used as other.
87768776
8777-
inplace : boolean, default False
8777+
inplace : bool, default False
87788778
Whether to perform the operation in place on the data.
87798779
axis : int, default None
87808780
Alignment axis if needed.
87818781
level : int, default None
87828782
Alignment level if needed.
8783-
errors : str, {'raise', 'ignore'}, default `raise`
8783+
errors : str, {'raise', 'ignore'}, default 'raise'
87848784
Note that currently this parameter won't affect
87858785
the results and will always coerce to a suitable dtype.
87868786
8787-
- `raise` : allow exceptions to be raised.
8788-
- `ignore` : suppress exceptions. On error return original object.
8787+
- 'raise' : allow exceptions to be raised.
8788+
- 'ignore' : suppress exceptions. On error return original object.
87898789
8790-
try_cast : boolean, default False
8790+
try_cast : bool, default False
87918791
Try to cast the result back to the input type (if possible).
8792-
raise_on_error : boolean, default True
8792+
raise_on_error : bool, default True
87938793
Whether to raise on invalid data types (e.g. trying to where on
87948794
strings).
87958795
@@ -8799,7 +8799,7 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
87998799
88008800
Returns
88018801
-------
8802-
wh : same type as caller
8802+
Same type as caller
88038803
88048804
See Also
88058805
--------
@@ -8848,6 +8848,13 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
88488848
dtype: int64
88498849
88508850
>>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B'])
8851+
>>> df
8852+
A B
8853+
0 0 1
8854+
1 2 3
8855+
2 4 5
8856+
3 6 7
8857+
4 8 9
88518858
>>> m = df %% 3 == 0
88528859
>>> df.where(m, -df)
88538860
A B

0 commit comments

Comments
 (0)