bpd.Series.take

Series.take(indices)[source]

Return the elements in the given positional indices.

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.
Returns:taken – A Series containing the elements taken from the object.
Return type:Series
Raises:IndexError – If any indices are out of bounds with respect to Series length.

Examples

>>> s = bpd.Series(data=[1, 2, 3], index=['A', 'B', 'C'])
>>> s.take([0, 3])
A    1
C    3
dtype: int64
>>> s.take(np.arange(2))
A    1
B    2
dtype: int64