Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Expanding Functionality of the .iloc[] Attribute | Getting Familiar With Indexing and Selecting Data
Advanced Techniques in pandas
course content

Зміст курсу

Advanced Techniques in pandas

Advanced Techniques in pandas

1. Getting Familiar With Indexing and Selecting Data
2. Dealing With Conditions
3. Extracting Data
4. Aggregating Data
5. Preprocessing Data

bookExpanding Functionality of the .iloc[] Attribute

We will learn some new features that iloc[] provides. The coolest one is that we can specify indices of both rows and columns. This attribute is similar to .loc[], but the last index of the slicing is exclusive.

Look at the example and the relevant output:

  • data.iloc[1, 2] - extracts the item located in the dataset's second row and third column. The first index corresponds to the row index, and the second to the column index. Indeed, you can skip one of them;
  • data.iloc[:, 3] - extracts all values from the rows of the fourth column 'IMDb-Rating';
  • data.iloc[3, :] or data.iloc[3] - extracts the 4th row and all relevant columns;
  • data.iloc[:2, 1:4] - extracts the first two rows and column with the indices 1, 2, 3;
  • data.iloc[[2,4],[1,3]] - extracts the rows with indices 2,4 and columns with the indices 1, 3.
Завдання
test

Swipe to show code editor

Your task here is just to practice. Output information on the first 50 rows and the columns with indices 1 and 4.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 6
toggle bottom row

bookExpanding Functionality of the .iloc[] Attribute

We will learn some new features that iloc[] provides. The coolest one is that we can specify indices of both rows and columns. This attribute is similar to .loc[], but the last index of the slicing is exclusive.

Look at the example and the relevant output:

  • data.iloc[1, 2] - extracts the item located in the dataset's second row and third column. The first index corresponds to the row index, and the second to the column index. Indeed, you can skip one of them;
  • data.iloc[:, 3] - extracts all values from the rows of the fourth column 'IMDb-Rating';
  • data.iloc[3, :] or data.iloc[3] - extracts the 4th row and all relevant columns;
  • data.iloc[:2, 1:4] - extracts the first two rows and column with the indices 1, 2, 3;
  • data.iloc[[2,4],[1,3]] - extracts the rows with indices 2,4 and columns with the indices 1, 3.
Завдання
test

Swipe to show code editor

Your task here is just to practice. Output information on the first 50 rows and the columns with indices 1 and 4.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 6
toggle bottom row

bookExpanding Functionality of the .iloc[] Attribute

We will learn some new features that iloc[] provides. The coolest one is that we can specify indices of both rows and columns. This attribute is similar to .loc[], but the last index of the slicing is exclusive.

Look at the example and the relevant output:

  • data.iloc[1, 2] - extracts the item located in the dataset's second row and third column. The first index corresponds to the row index, and the second to the column index. Indeed, you can skip one of them;
  • data.iloc[:, 3] - extracts all values from the rows of the fourth column 'IMDb-Rating';
  • data.iloc[3, :] or data.iloc[3] - extracts the 4th row and all relevant columns;
  • data.iloc[:2, 1:4] - extracts the first two rows and column with the indices 1, 2, 3;
  • data.iloc[[2,4],[1,3]] - extracts the rows with indices 2,4 and columns with the indices 1, 3.
Завдання
test

Swipe to show code editor

Your task here is just to practice. Output information on the first 50 rows and the columns with indices 1 and 4.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

We will learn some new features that iloc[] provides. The coolest one is that we can specify indices of both rows and columns. This attribute is similar to .loc[], but the last index of the slicing is exclusive.

Look at the example and the relevant output:

  • data.iloc[1, 2] - extracts the item located in the dataset's second row and third column. The first index corresponds to the row index, and the second to the column index. Indeed, you can skip one of them;
  • data.iloc[:, 3] - extracts all values from the rows of the fourth column 'IMDb-Rating';
  • data.iloc[3, :] or data.iloc[3] - extracts the 4th row and all relevant columns;
  • data.iloc[:2, 1:4] - extracts the first two rows and column with the indices 1, 2, 3;
  • data.iloc[[2,4],[1,3]] - extracts the rows with indices 2,4 and columns with the indices 1, 3.
Завдання
test

Swipe to show code editor

Your task here is just to practice. Output information on the first 50 rows and the columns with indices 1 and 4.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 1. Розділ 6
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt