Skip to content

Commit ca2abb3

Browse files
authored
Update datetimelike.py
1 parent f2ce218 commit ca2abb3

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

pandas/core/indexes/datetimelike.py

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -844,30 +844,47 @@ def take(
844844
**kwargs,
845845
) -> Self:
846846
"""
847-
Return a new Index of the values selected by the indices.
848-
849847
For internal compatibility with numpy arrays.
850848
851849
Parameters
852850
----------
853851
indices : array-like
854852
Indices to be taken.
855-
axis : int, optional
856-
The axis over which to select values. Always 0.
853+
axis : {0 or 'index'}, optional
854+
The axis over which to select values, always 0 or 'index'.
857855
allow_fill : bool, default True
856+
How to handle negative values in `indices`.
857+
858+
* False: negative values in `indices` indicate positional indices
859+
from the right (the default). This is similar to
860+
:func:`numpy.take`.
861+
862+
* True: negative values in `indices` indicate
863+
missing values. These values are set to `fill_value`. Any other
864+
other negative values raise a ``ValueError``.
865+
858866
fill_value : scalar, default None
859-
If allow_fill=True and fill_value is not None, this value is used
860-
instead of raising if the index is out of bounds.
861-
867+
If allow_fill=True and fill_value is not None, indices specified by
868+
-1 are regarded as NA. If Index doesn't hold NA, raise ValueError.
869+
**kwargs
870+
Required for compatibility with numpy.
871+
862872
Returns
863873
-------
864874
Index
865-
An element of same type as self.
866-
875+
An index formed of elements at the given indices. Will be the same
876+
type as self, except for RangeIndex.
877+
867878
See Also
868879
--------
869-
numpy.ndarray.take : Return an array formed from the elements of a
870-
at the given indices.
880+
numpy.ndarray.take: Return an array formed from the
881+
elements of a at the given indices.
882+
883+
Examples
884+
--------
885+
>>> idx = pd.Index(['a', 'b', 'c'])
886+
>>> idx.take([2, 2, 1, 2])
887+
Index(['c', 'c', 'b', 'c'], dtype='str')
871888
"""
872889
nv.validate_take((), kwargs)
873890
indices = np.asarray(indices, dtype=np.intp)

0 commit comments

Comments
 (0)