Learn Before
Pandas DataFrame .iloc Slicing
.iloc is integer position based, so you must use the row or column integer position to access the data.
Given the pictured dataframe,
If you want to access all of the “viper” values you would run...
df.iloc[1]
This would return a Pandas Series of the “viper” row.
If you want to extract multiple rows, you can include the integer values in a list like...
df.iloc[[0,1]]
This returns a Pandas Dataframe of all of the values from both the “cobra” and “viper” rows.
To get a single value such as the max_speed of a sidewinder, you can use...
df.iloc[2,0]
This would return a single integer value of 7.
The syntax for the above example is...
df.iloc[row_number, column_number]
Remember that Python is a zero-based indexing language so a row or column in the first position has a row or column number of 0 and not 1.

0
1
Tags
Python Programming Language
Data Science