Run ❯
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
import pandas as pd data = { '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) print(df.groupby(["car"]).mean())
co2 car Ford 100.5 Skoda 97.0