pandas/iloc

Select by Position

Select rows and columns by integer position

pandas
dataframe
iloc

Command

df.iloc

Explanation

df.iloc[] is integer-location-based indexing to select rows and columns.

Examples

Select first row

df.iloc[0]

Select first row, second column

df.iloc[0, 1]

Select first two columns

df.iloc[:, 0:2]