modin.pandas.Series.take¶

Series.take(indices, axis=0, **kwargs)[source]¶

Return the elements in the given positional indices along an axis.

This means that we are not indexing according to actual values in the index attribute of the object. We are indexing according to the actual position of the element in the object.

Parameters:
  • indices (array-like) – An array of ints indicating which positions to take.

  • 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. For Series this parameter is unused and defaults to 0.

  • **kwargs – For compatibility with numpy.take(). Has no effect on the output.

Returns:

An array-like containing the elements taken from the object.

Return type:

same type as caller

See also

Series.take

Take a subset of a Series by the given positional indices.

DataFrame.loc

Select a subset of a DataFrame by labels.

DataFrame.iloc

Select a subset of a DataFrame by positions.

Examples

>>> ser = pd.Series([-1, 5, 6, 2, 4])
>>> ser
0   -1
1    5
2    6
3    2
4    4
dtype: int64
Copy

Take elements at positions 0 and 3 along the axis 0 (default).

>>> ser.take([0, 3])
0   -1
3    2
dtype: int64
Copy

We may take elements using negative integers for positive indices, starting from the end of the object, just like with Python lists.

>>> ser.take([-1, -2])
4    4
3    2
dtype: int64
Copy