Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Selecting Specific Rows and Columns | 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

Selecting Specific Rows and Columns

Okay, you've dealt with the previous chapters, and now is the right time to combine your knowledge. You can specify both rows and columns; to do so, you just need to be familiar with the .loc[] attribute.

This function allows us to do plenty of different slicing operations, but for now, we will just consolidate knowledge from the previous chapters.

As usual, look at the example and then at the output.

  • data.loc[2:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 2, 3, 4, 5(but remember that the indices start from 0) from the columns 'Director' and 'ReleaseYear'(.loc[] includes the last index that you put into []);
  • data.loc[:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 0, 1, 2, 3, 4, 5 from the columns 'Director' and 'ReleaseYear';
  • data.loc[997:, ['Director', 'ReleaseYear']] - outputs rows with the indices 997, 998, 999 (999 is the index of the last row) from the columns 'Director' and 'ReleaseYear';
  • data.loc[:, ['Director', 'ReleaseYear']] or data[['Director', 'ReleaseYear']] - outputs all rows from the columns 'Director' and 'ReleaseYear'.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

Все було зрозуміло?

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

Selecting Specific Rows and Columns

Okay, you've dealt with the previous chapters, and now is the right time to combine your knowledge. You can specify both rows and columns; to do so, you just need to be familiar with the .loc[] attribute.

This function allows us to do plenty of different slicing operations, but for now, we will just consolidate knowledge from the previous chapters.

As usual, look at the example and then at the output.

  • data.loc[2:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 2, 3, 4, 5(but remember that the indices start from 0) from the columns 'Director' and 'ReleaseYear'(.loc[] includes the last index that you put into []);
  • data.loc[:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 0, 1, 2, 3, 4, 5 from the columns 'Director' and 'ReleaseYear';
  • data.loc[997:, ['Director', 'ReleaseYear']] - outputs rows with the indices 997, 998, 999 (999 is the index of the last row) from the columns 'Director' and 'ReleaseYear';
  • data.loc[:, ['Director', 'ReleaseYear']] or data[['Director', 'ReleaseYear']] - outputs all rows from the columns 'Director' and 'ReleaseYear'.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

Все було зрозуміло?

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

Selecting Specific Rows and Columns

Okay, you've dealt with the previous chapters, and now is the right time to combine your knowledge. You can specify both rows and columns; to do so, you just need to be familiar with the .loc[] attribute.

This function allows us to do plenty of different slicing operations, but for now, we will just consolidate knowledge from the previous chapters.

As usual, look at the example and then at the output.

  • data.loc[2:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 2, 3, 4, 5(but remember that the indices start from 0) from the columns 'Director' and 'ReleaseYear'(.loc[] includes the last index that you put into []);
  • data.loc[:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 0, 1, 2, 3, 4, 5 from the columns 'Director' and 'ReleaseYear';
  • data.loc[997:, ['Director', 'ReleaseYear']] - outputs rows with the indices 997, 998, 999 (999 is the index of the last row) from the columns 'Director' and 'ReleaseYear';
  • data.loc[:, ['Director', 'ReleaseYear']] or data[['Director', 'ReleaseYear']] - outputs all rows from the columns 'Director' and 'ReleaseYear'.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

Все було зрозуміло?

Okay, you've dealt with the previous chapters, and now is the right time to combine your knowledge. You can specify both rows and columns; to do so, you just need to be familiar with the .loc[] attribute.

This function allows us to do plenty of different slicing operations, but for now, we will just consolidate knowledge from the previous chapters.

As usual, look at the example and then at the output.

  • data.loc[2:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 2, 3, 4, 5(but remember that the indices start from 0) from the columns 'Director' and 'ReleaseYear'(.loc[] includes the last index that you put into []);
  • data.loc[:5, ['Director', 'ReleaseYear']] - outputs rows with the indices 0, 1, 2, 3, 4, 5 from the columns 'Director' and 'ReleaseYear';
  • data.loc[997:, ['Director', 'ReleaseYear']] - outputs rows with the indices 997, 998, 999 (999 is the index of the last row) from the columns 'Director' and 'ReleaseYear';
  • data.loc[:, ['Director', 'ReleaseYear']] or data[['Director', 'ReleaseYear']] - outputs all rows from the columns 'Director' and 'ReleaseYear'.

Завдання

Your task here is to output the necessary rows and columns. Follow the algorithm:

  1. Import the pandas library with the pd alias.
  2. Read the csv file.
  3. Assign to data variable information about the columns 'Title', 'Stars', 'Category'(in this order) with rows with indices from 15 to 85.
  4. Output the data_extracted variable.

Once you've completed this task, click the button below the code to check your solution.

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