Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Function iloc() 1/2 | The Very First Steps
Pandas First Steps

Function iloc() 1/2

You can also access rows in a DataFrame by their index. There are multiple ways to do this:

  • .iloc - is used to access rows by their numerical index, starting from 0;
  • .loc - is used to access rows by their string label.

In this course, we will focus exclusively on using the .iloc() function.

First, let's create a DataFrame to work with.

The DataFrame has the following structure:

Example

You can notice the first column, which serves as the row index. We'll use these indexes to access specific rows in the DataFrame. Now let's examine the syntax of this function:

Now it's time to apply this function to our DataFrame.

After running the above code, you'll get rows that correspond to the indexes indicated in the image below:

Example

Everything was clear?

Section 1. Chapter 13
course content

Course Content

Pandas First Steps

Function iloc() 1/2

You can also access rows in a DataFrame by their index. There are multiple ways to do this:

  • .iloc - is used to access rows by their numerical index, starting from 0;
  • .loc - is used to access rows by their string label.

In this course, we will focus exclusively on using the .iloc() function.

First, let's create a DataFrame to work with.

The DataFrame has the following structure:

Example

You can notice the first column, which serves as the row index. We'll use these indexes to access specific rows in the DataFrame. Now let's examine the syntax of this function:

Now it's time to apply this function to our DataFrame.

After running the above code, you'll get rows that correspond to the indexes indicated in the image below:

Example

Everything was clear?

Section 1. Chapter 13
some-alt