bpd.DataFrame.take

DataFrame.take(indices)[source]

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

Examples

>>> df = bpd.DataFrame().assign(name=['falcon', 'parrot', 'lion'],
...                             kind=['bird', 'bird', 'mammal'])
>>> df
     name    kind
0  falcon    bird
1  parrot    bird
2    lion  mammal
>>> df.take([0, 2])
     name    kind
0  falcon    bird
2    lion  mammal