Indexing by Position
Explore how to index pandas DataFrames by position using iloc. Understand selecting rows and columns with scalars, lists, slices, and functions to extract data as Series or DataFrames. Gain hands-on knowledge of versatile position-based data selection techniques.
We'll cover the following...
We'll cover the following...
The iloc attribute gives us the ability to pull out rows and columns from a DataFrame. Here we pull out row position 1. Note that this returns the result as a Series (even though it represents a row):
In the next example, instead of passing in scalar position, we’re going to pass in row position 1 in a list. Sometimes we’ll hear people tell ...