Skip to content

Commit 8c7d1f6

Browse files
gmacarioTomAugspurger
authored andcommitted
DOC: Improve the docstring of Series.take (pandas-dev#20179)
1 parent 8d82cce commit 8c7d1f6

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

pandas/core/generic.py

+27-21
Original file line numberDiff line numberDiff line change
@@ -2722,28 +2722,43 @@ def _take(self, indices, axis=0, convert=True, is_copy=True):
27222722
----------
27232723
indices : array-like
27242724
An array of ints indicating which positions to take.
2725-
axis : int, default 0
2726-
The axis on which to select elements. "0" means that we are
2727-
selecting rows, "1" means that we are selecting columns, etc.
2725+
axis : {0 or 'index', 1 or 'columns', None}, default 0
2726+
The axis on which to select elements. ``0`` means that we are
2727+
selecting rows, ``1`` means that we are selecting columns.
27282728
convert : bool, default True
2729-
.. deprecated:: 0.21.0
2730-
In the future, negative indices will always be converted.
2731-
27322729
Whether to convert negative indices into positive ones.
27332730
For example, ``-1`` would map to the ``len(axis) - 1``.
27342731
The conversions are similar to the behavior of indexing a
27352732
regular Python list.
2733+
2734+
.. deprecated:: 0.21.0
2735+
In the future, negative indices will always be converted.
2736+
27362737
is_copy : bool, default True
27372738
Whether to return a copy of the original object or not.
2739+
**kwargs
2740+
For compatibility with :meth:`numpy.take`. Has no effect on the
2741+
output.
2742+
2743+
Returns
2744+
-------
2745+
taken : type of caller
2746+
An array-like containing the elements taken from the object.
2747+
2748+
See Also
2749+
--------
2750+
DataFrame.loc : Select a subset of a DataFrame by labels.
2751+
DataFrame.iloc : Select a subset of a DataFrame by positions.
2752+
numpy.take : Take elements from an array along an axis.
27382753
27392754
Examples
27402755
--------
27412756
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
2742-
('parrot', 'bird', 24.0),
2743-
('lion', 'mammal', 80.5),
2744-
('monkey', 'mammal', np.nan)],
2745-
columns=('name', 'class', 'max_speed'),
2746-
index=[0, 2, 3, 1])
2757+
... ('parrot', 'bird', 24.0),
2758+
... ('lion', 'mammal', 80.5),
2759+
... ('monkey', 'mammal', np.nan)],
2760+
... columns=['name', 'class', 'max_speed'],
2761+
... index=[0, 2, 3, 1])
27472762
>>> df
27482763
name class max_speed
27492764
0 falcon bird 389.0
@@ -2758,6 +2773,7 @@ def _take(self, indices, axis=0, convert=True, is_copy=True):
27582773
and 3rd rows, not rows whose indices equal 0 and 3.
27592774
27602775
>>> df.take([0, 3])
2776+
name class max_speed
27612777
0 falcon bird 389.0
27622778
1 monkey mammal NaN
27632779
@@ -2777,16 +2793,6 @@ class max_speed
27772793
name class max_speed
27782794
1 monkey mammal NaN
27792795
3 lion mammal 80.5
2780-
2781-
Returns
2782-
-------
2783-
taken : type of caller
2784-
An array-like containing the elements taken from the object.
2785-
2786-
See Also
2787-
--------
2788-
numpy.ndarray.take
2789-
numpy.take
27902796
"""
27912797

27922798
@Appender(_shared_docs['take'])

0 commit comments

Comments
 (0)