Skip to content

Commit 7d405cd

Browse files
committed
DOC: EX01 Add Examples section in Index.where
1 parent cab9624 commit 7d405cd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/core/indexes/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,6 +3973,17 @@ def where(self, cond, other=None):
39733973
See Also
39743974
--------
39753975
DataFrame.where : Replace values in a DataFrame where the condition is False.
3976+
3977+
Examples
3978+
--------
3979+
>>> idx1 = pd.Index([42, 21, 34, 96, 72])
3980+
>>> idx1
3981+
Int64Index([42, 21, 34, 96, 72], dtype='int64')
3982+
>>> idx2 = pd.Index([140, 150, 140, 190, 170])
3983+
>>> idx2
3984+
Int64Index([140, 150, 140, 190, 170], dtype='int64')
3985+
>>> idx1.where((idx2 - 100) > idx1, idx2)
3986+
Int64Index([140, 21, 34, 190, 170], dtype='int64')
39763987
"""
39773988
if other is None:
39783989
other = self._na_value

0 commit comments

Comments
 (0)