Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Is Data in ...?
course content

Course Content

Advanced Techniques in pandas

Is Data in ...?Is Data in ...?

In this section, we will continue extracting data using specific conditions. Here, you will become familiar with the helpful function called .isin(). But firstly, you need to examine the dataset. Look at the first five rows:

Now, take a look at the example and the explanation below:

Explanation:

If you remember, we always put the conditions inside the .loc[] function. Here, we do the same. The .isin(list) function checks if the values from the column are in the array. In our case, we check if values from the column 'Manufacturer' are in the list models.

Task

Your task here is to extract data about cars where values from the column 'Color' are equal to 'Grey', 'White', 'Black'. Follow the algorithm to easily manage with the task:

  1. Create the colors list with the elements 'Grey', 'White', 'Black' (in this order).
  2. Extract values from the column 'Color' that the list color consists of. Use the .loc[] function.
  3. Output the last five rows of the dataset data_extracted.

Everything was clear?

Section 3. Chapter 1
Switch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt