Series.take()
Pandas Series.take()
returns items at given positional indices along the axis ... Here we are not indexing according to the actual values in the index attribute of the object. We index according to the actual position of the element in the object.
Syntax: Series.take (indices, axis = 0, convert = None, is_copy = True, ** kwargs)
Parameter:
indices: An array of ints indicating which positions to take.
axis: The axis on which to select elements.
-" 0 means that we are selecting rows.
-" 1 means that we are selecting columns.
convert: Whether to convert negative indices into positive ones
is_copy: Whether to return a copy of the original object or not.
** kwargs: For compatibility with numpy.take (). Has no effect on the output.Returns: taken: same type as caller
Example # 1: Use Series.take ()
to extract some elements from a given series object based on the actual position of the elements in the object.
|
Output:
We will now use Series.take ()
to retrieve the values corresponding to the traversed positions.
|
Output:
As we can see in the output, Series.take ()
successfully returned elements matching the passed index positions of this series object.
Example # 2: Use Series.take ()
to extract some elements from a given series object based on the actual position of the elements in the object.
|
Output:
We will now use Series.take ()
to retrieve values corresponding to the positions passed.
|
Output:
As we can see in the output, Series.take ()
successfully returned elements matching the passed index positions of this series object.