course content

Course Content

Advanced Techniques in pandas

Combine Your KnowledgeCombine Your Knowledge

If you remember, several chapters ago you were provided with information on how to write several conditions simultaneously. With the .isin() statement, you can use the same rules. For instance, an example from the previous chapter could look like this:

The output in these two cases will be the same.

Your task here is to make the data satisfy three conditions: cars' categories are 'Sedan', 'Jeep', 'Coupe', AND the car has a leather interior (`'Leather_interior' == Yes`), AND the types of gear box are 'Variator' or 'Automatic'.

import pandas as pd
data = pd.read_csv('', index_col = 0)

categories = ['Sedan', 'Jeep', 'Coupe']
gear_box = ['Variator', 'Automatic']

condition_1 = data['Category'].

condition_2 = data['Leather_interior']
condition_3 = data['Gear_box_type'].

data_extracted = data.loc[condition_1

Everything was clear?

Section 3. Chapter 2