W3docs

Selecting a row of pandas series/dataframe by integer index

You can use the .iloc[] property to select a row by its integer index in a pandas DataFrame or Series.

You can use the .iloc[] property to select a row by its integer index in a pandas DataFrame or Series. Note: .iloc[] selects by integer position, while .loc[] selects by label.

Select a row by its integer index in a pandas DataFrame or Series in Python

python— editable, runs on the server

This will output:

Output

name    Bob
age      30
Name: 1, dtype: object

Select multiple rows by integer indices in a pandas DataFrame or Series in Python

rows = df.iloc[[0, 2]]
print(rows)

This will output:

name  age
0  John   25
2  Sara   35