Skip to content

DOC: Improve the docstring of Series.take #20179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2521,28 +2521,43 @@ def _take(self, indices, axis=0, convert=True, is_copy=True):
----------
indices : array-like
An array of ints indicating which positions to take.
axis : int, default 0
The axis on which to select elements. "0" means that we are
selecting rows, "1" means that we are selecting columns, etc.
axis : {0 or 'index', 1 or 'columns', None}, default 0
The axis on which to select elements. ``0`` means that we are
selecting rows, ``1`` means that we are selecting columns.
convert : bool, default True
.. deprecated:: 0.21.0
In the future, negative indices will always be converted.

Whether to convert negative indices into positive ones.
For example, ``-1`` would map to the ``len(axis) - 1``.
The conversions are similar to the behavior of indexing a
regular Python list.

.. deprecated:: 0.21.0
In the future, negative indices will always be converted.

is_copy : bool, default True
Whether to return a copy of the original object or not.
**kwargs
For compatibility with :meth:`numpy.take`. Has no effect on the
output.

Returns
-------
taken : type of caller
An array-like containing the elements taken from the object.

See Also
--------
DataFrame.loc : Select a subset of a DataFrame by labels.
DataFrame.iloc : Select a subset of a DataFrame by positions.
numpy.take : Take elements from an array along an axis.

Examples
--------
>>> df = pd.DataFrame([('falcon', 'bird', 389.0),
('parrot', 'bird', 24.0),
('lion', 'mammal', 80.5),
('monkey', 'mammal', np.nan)],
columns=('name', 'class', 'max_speed'),
index=[0, 2, 3, 1])
... ('parrot', 'bird', 24.0),
... ('lion', 'mammal', 80.5),
... ('monkey', 'mammal', np.nan)],
... columns=['name', 'class', 'max_speed'],
... index=[0, 2, 3, 1])
>>> df
name class max_speed
0 falcon bird 389.0
Expand All @@ -2557,6 +2572,7 @@ def _take(self, indices, axis=0, convert=True, is_copy=True):
and 3rd rows, not rows whose indices equal 0 and 3.

>>> df.take([0, 3])
name class max_speed
0 falcon bird 389.0
1 monkey mammal NaN

Expand All @@ -2576,16 +2592,6 @@ class max_speed
name class max_speed
1 monkey mammal NaN
3 lion mammal 80.5

Returns
-------
taken : type of caller
An array-like containing the elements taken from the object.

See Also
--------
numpy.ndarray.take
numpy.take
"""

@Appender(_shared_docs['take'])
Expand Down