w3resource

Pandas DataFrame: take() function

DataFrame - take() function

The take() function is used to get 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.

Syntax:

DataFrame.take(self, indices, axis=0, is_copy=True, **kwargs)

Parameters:

Name Description Type/Default Value Required / Optional
indices                              An array of ints indicating which positions to take.
array-like

Required
axis  The axis on which to select elements. 0 means that we are selecting rows, 1 means that we are selecting columns. {0 or ‘index’, 1 or ‘columns’, None}
Default Value: 0
Required
is_copy  Whether to return a copy of the original object or not. bool
Default Value: True
Required
**kwargs

For compatibility with numpy.take(). Has no effect on the output.   Required

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

Example:


Download the Pandas DataFrame Notebooks from here.

Previous: DataFrame - set_index() function
Next: DataFrame - dropna() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/dataframe/dataframe-take.php