Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

Pandas DataFrame take() Method

❮ DataFrame Reference


Example

Return row 5 and 10 from the DataFrame.

In this example we use a .csv file called data.csv

import pandas as pd

df = pd.read_csv('data.csv')

print(df.take([5, 10]))
Try it Yourself »

Definition and Usage

The take() method returns the specified rows from the DataFrame.

The take() method needs the row positions, even if the rows has named indexes.


Syntax

dataframe.take(indexes, axis, kwargs)

Parameters

The axis parameter is a keyword argument.

Parameter Value Description
indexes List Required. An array of the positions to return
axis 0
1
'index'
'columns'
Optional, default 0. The axis to select elements from
kwargs 0
1
'index'
'columns'
Optional, default 0. The axis to select elements from

Return Value

A DataFrame with the selected rows/columns.


❮ DataFrame Reference