Skip to content

Commit 49c0c8d

Browse files
committed
DOC: EX01 Add Examples section in Index.where
1 parent 2d7af91 commit 49c0c8d

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
@@ -3956,6 +3956,17 @@ def where(self, cond, other=None):
39563956
See Also
39573957
--------
39583958
DataFrame.where : Replace values in a DataFrame where the condition is False.
3959+
3960+
Examples
3961+
--------
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')
39593970
"""
39603971
if other is None:
39613972
other = self._na_value

0 commit comments

Comments
 (0)