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.


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


Name Description Type/Default Value Required / Optional
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. {0 or ‘index’, 1 or ‘columns’, None}
Default Value: 0
is_copy  Whether to return a copy of the original object or not. bool
Default Value: True

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.


Download the Pandas DataFrame Notebooks from here.

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

Follow us on Facebook and Twitter for latest update.