Examples
import numpy as np
import pandas as pd
df = pd.DataFrame([('eagle', 'bird', 320.0),
('sparrow', 'bird', 30.0),
('tiger', 'mammal', 90.5),
('deer', 'mammal', np.nan)],
columns=['name', 'class', 'max_speed'],
index=[0, 2, 3, 1])
df
Take elements at positions 0 and 3 along the axis 0 (default):
df.take([0, 3])
Take elements at indices 1 and 2 along the axis 1 (column selection):
df.take([1, 2], axis=1)
We may take elements using negative integers for positive indices, starting from the
end of the object, just like with Python lists:
df.take([-1, -2])