@@ -7778,9 +7778,7 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
7778
7778
return self ._constructor (new_data ).__finalize__ (self )
7779
7779
7780
7780
_shared_docs ['where' ] = ("""
7781
- Return an object of same shape as self and whose corresponding
7782
- entries are from self where `cond` is %(cond)s and otherwise are from
7783
- `other`.
7781
+ Replace values where the condition is %(cond_rev)s.
7784
7782
7785
7783
Parameters
7786
7784
----------
@@ -7805,24 +7803,28 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
7805
7803
A callable can be used as other.
7806
7804
7807
7805
inplace : boolean, default False
7808
- Whether to perform the operation in place on the data
7809
- axis : alignment axis if needed, default None
7810
- level : alignment level if needed, default None
7811
- errors : str, {'raise', 'ignore'}, default 'raise'
7812
- - ``raise`` : allow exceptions to be raised
7813
- - ``ignore`` : suppress exceptions. On error return original object
7814
-
7806
+ Whether to perform the operation in place on the data.
7807
+ axis : int, default None
7808
+ Alignment axis if needed.
7809
+ level : int, default None
7810
+ Alignment level if needed.
7811
+ errors : str, {'raise', 'ignore'}, default `raise`
7815
7812
Note that currently this parameter won't affect
7816
7813
the results and will always coerce to a suitable dtype.
7817
7814
7815
+ - `raise` : allow exceptions to be raised.
7816
+ - `ignore` : suppress exceptions. On error return original object.
7817
+
7818
7818
try_cast : boolean, default False
7819
- try to cast the result back to the input type (if possible),
7819
+ Try to cast the result back to the input type (if possible).
7820
7820
raise_on_error : boolean, default True
7821
7821
Whether to raise on invalid data types (e.g. trying to where on
7822
- strings)
7822
+ strings).
7823
7823
7824
7824
.. deprecated:: 0.21.0
7825
7825
7826
+ Use `errors`.
7827
+
7826
7828
Returns
7827
7829
-------
7828
7830
wh : same type as caller
@@ -7841,6 +7843,11 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
7841
7843
For further details and examples see the ``%(name)s`` documentation in
7842
7844
:ref:`indexing <indexing.where_mask>`.
7843
7845
7846
+ See Also
7847
+ --------
7848
+ :func:`DataFrame.%(name_other)s` : Return an object of same shape as
7849
+ self
7850
+
7844
7851
Examples
7845
7852
--------
7846
7853
>>> s = pd.Series(range(5))
@@ -7850,20 +7857,23 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
7850
7857
2 2.0
7851
7858
3 3.0
7852
7859
4 4.0
7860
+ dtype: float64
7853
7861
7854
7862
>>> s.mask(s > 0)
7855
7863
0 0.0
7856
7864
1 NaN
7857
7865
2 NaN
7858
7866
3 NaN
7859
7867
4 NaN
7868
+ dtype: float64
7860
7869
7861
7870
>>> s.where(s > 1, 10)
7862
- 0 10.0
7863
- 1 10.0
7864
- 2 2.0
7865
- 3 3.0
7866
- 4 4.0
7871
+ 0 10
7872
+ 1 10
7873
+ 2 2
7874
+ 3 3
7875
+ 4 4
7876
+ dtype: int64
7867
7877
7868
7878
>>> df = pd.DataFrame(np.arange(10).reshape(-1, 2), columns=['A', 'B'])
7869
7879
>>> m = df %% 3 == 0
@@ -7888,10 +7898,6 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
7888
7898
2 True True
7889
7899
3 True True
7890
7900
4 True True
7891
-
7892
- See Also
7893
- --------
7894
- :func:`DataFrame.%(name_other)s`
7895
7901
""" )
7896
7902
7897
7903
@Appender (_shared_docs ['where' ] % dict (_shared_doc_kwargs , cond = "True" ,
0 commit comments