Run ❯
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
import pandas as pd data = { 'weight': [929, 1109, 1112, 1119, 1328, 1584, 1415, 1235], 'co2': [95, 90, 99, 104, 105, 94, 99, 104], 'model': ['Citigo', 'Fabia', 'Fiesta', 'Rapid', 'Focus', 'Mondeo', 'Octavia', 'B-Max'], 'car': ['Skoda', 'Skoda', 'Ford', 'Skoda', 'Ford', 'Ford', 'Skoda', 'Ford'] } df = pd.DataFrame(data) df = df.set_index(['car', 'model']) print(df.xs('Ford'))
weight co2 model Fiesta 1112 99 Focus 1328 105 Mondeo 1584 94 B-Max 1235 104