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

Contenido del Curso

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

bookIs Data in ...?

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

123
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) print(data.head())
copy

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

12345
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) models = ['HONDA', 'FORD', 'MERCEDES-BENZ', 'HYUNDAI'] data_extracted = data.loc[data['Manufacturer'].isin(models)] print(data_extracted.head())
copy

Explanation:

If you remember, we always put the conditions inside the .loc[] attribute. Here, we do the same. The .isin(list) method 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.

Tarea
test

Swipe to show code editor

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[] attribute.
  3. Output the last five rows of the dataset data_extracted.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 1
toggle bottom row

bookIs Data in ...?

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

123
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) print(data.head())
copy

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

12345
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) models = ['HONDA', 'FORD', 'MERCEDES-BENZ', 'HYUNDAI'] data_extracted = data.loc[data['Manufacturer'].isin(models)] print(data_extracted.head())
copy

Explanation:

If you remember, we always put the conditions inside the .loc[] attribute. Here, we do the same. The .isin(list) method 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.

Tarea
test

Swipe to show code editor

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[] attribute.
  3. Output the last five rows of the dataset data_extracted.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 1
toggle bottom row

bookIs Data in ...?

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

123
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) print(data.head())
copy

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

12345
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) models = ['HONDA', 'FORD', 'MERCEDES-BENZ', 'HYUNDAI'] data_extracted = data.loc[data['Manufacturer'].isin(models)] print(data_extracted.head())
copy

Explanation:

If you remember, we always put the conditions inside the .loc[] attribute. Here, we do the same. The .isin(list) method 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.

Tarea
test

Swipe to show code editor

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[] attribute.
  3. Output the last five rows of the dataset data_extracted.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

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

123
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) print(data.head())
copy

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

12345
import pandas as pd data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/4bf24830-59ba-4418-969b-aaf8117d522e/cars.csv', index_col = 0) models = ['HONDA', 'FORD', 'MERCEDES-BENZ', 'HYUNDAI'] data_extracted = data.loc[data['Manufacturer'].isin(models)] print(data_extracted.head())
copy

Explanation:

If you remember, we always put the conditions inside the .loc[] attribute. Here, we do the same. The .isin(list) method 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.

Tarea
test

Swipe to show code editor

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[] attribute.
  3. Output the last five rows of the dataset data_extracted.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 3. Capítulo 1
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt