Skip to content

Commit 8c35656

Browse files
committed
DOC: move Index.where to shared_docs
1 parent e4502bf commit 8c35656

File tree

3 files changed

+6
-26
lines changed

3 files changed

+6
-26
lines changed

pandas/indexes/base.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,7 @@ def repeat(self, repeats, *args, **kwargs):
564564
nv.validate_repeat(args, kwargs)
565565
return self._shallow_copy(self._values.repeat(repeats))
566566

567-
def where(self, cond, other=None):
568-
"""
567+
_index_shared_docs['where'] = """
569568
.. versionadded:: 0.19.0
570569
571570
Return an Index of same shape as self and whose corresponding
@@ -577,6 +576,9 @@ def where(self, cond, other=None):
577576
cond : boolean same length as self
578577
other : scalar, or array-like
579578
"""
579+
580+
@Appender(_index_shared_docs['where'])
581+
def where(self, cond, other=None):
580582
if other is None:
581583
other = self._na_value
582584
values = np.where(cond, self.values, other)

pandas/indexes/category.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -332,19 +332,8 @@ def _can_reindex(self, indexer):
332332
""" always allow reindexing """
333333
pass
334334

335+
@Appender(_index_shared_docs['where'])
335336
def where(self, cond, other=None):
336-
"""
337-
.. versionadded:: 0.19.0
338-
339-
Return an Index of same shape as self and whose corresponding
340-
entries are from self where cond is True and otherwise are from
341-
other.
342-
343-
Parameters
344-
----------
345-
cond : boolean same length as self
346-
other : scalar, or array-like
347-
"""
348337
if other is None:
349338
other = self._na_value
350339
values = np.where(cond, self.values, other)

pandas/tseries/base.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -786,19 +786,8 @@ def repeat(self, repeats, *args, **kwargs):
786786
return self._shallow_copy(self.asi8.repeat(repeats),
787787
freq=freq)
788788

789+
@Appender(_index_shared_docs['where'])
789790
def where(self, cond, other=None):
790-
"""
791-
.. versionadded:: 0.19.0
792-
793-
Return an Index of same shape as self and whose corresponding
794-
entries are from self where cond is True and otherwise are from
795-
other.
796-
797-
Parameters
798-
----------
799-
cond : boolean same length as self
800-
other : scalar, or array-like
801-
"""
802791
other = _ensure_datetimelike_to_i8(other)
803792
values = _ensure_datetimelike_to_i8(self)
804793
result = np.where(cond, values, other).astype('i8')

0 commit comments

Comments
 (0)