@@ -3936,37 +3936,35 @@ def memory_usage(self, deep: bool = False) -> int:
3936
3936
3937
3937
def where (self , cond , other = None ):
3938
3938
"""
3939
- Return a copy of self with entries replaced where cond is False.
3939
+ Replace values where the condition is False.
3940
3940
3941
3941
The replacement is taken from other.
3942
3942
3943
3943
Parameters
3944
3944
----------
3945
3945
cond : bool array-like with the same length as self
3946
- Condition to select the entries on.
3946
+ Condition to select the values on.
3947
3947
other : scalar, or array-like, default None
3948
3948
Replacement if the condition is False.
3949
3949
3950
3950
Returns
3951
3951
-------
3952
3952
pandas.Index
3953
- Copy of self with entries replaced from other
3953
+ A copy of self with values replaced from other
3954
3954
where the condition is False.
3955
3955
3956
3956
See Also
3957
3957
--------
3958
- DataFrame.where : Replace values in a DataFrame where the condition is False.
3958
+ Series.where : Same method for Series.
3959
+ DataFrame.where : Same method for DataFrame.
3959
3960
3960
3961
Examples
3961
3962
--------
3962
- >>> idx1 = pd.Index([42, 21, 34, 96, 72])
3963
- >>> idx1
3964
- Int64Index([42, 21, 34, 96, 72], dtype='int64')
3965
- >>> idx2 = pd.Index([140, 150, 140, 190, 170])
3966
- >>> idx2
3967
- Int64Index([140, 150, 140, 190, 170], dtype='int64')
3968
- >>> idx1.where((idx2 - 100) > idx1, idx2)
3969
- Int64Index([140, 21, 34, 190, 170], dtype='int64')
3963
+ >>> idx = pd.Index(['car', 'bike', 'train', 'tractor'])
3964
+ >>> idx
3965
+ Index(['car', 'bike', 'train', 'tractor'], dtype='object')
3966
+ >>> idx.where(idx.isin(['car', 'train']), 'other')
3967
+ Index(['car', 'other', 'train', 'other'], dtype='object')
3970
3968
"""
3971
3969
if other is None :
3972
3970
other = self ._na_value
0 commit comments