An insight into vehicular carbon emissions and bicycle sales


This dataset captures the details of how CO2 emissions by a vehicle can vary with the different features. The dataset has been taken from Canada Government official open data website which contains data for over a period of 7 years. There are total 7385 rows and 12 columns. Listed below is few abbreviations to describe different data points.


  • 4WD/4X4 = Four-wheel drive
  • AWD = All-wheel drive
  • FFV = Flexible-fuel vehicle
  • SWB = Short wheelbase
  • LWB = Long wheelbase
  • EWB = Extended wheelbase


  • A = Automatic
  • AM = Automated manual
  • AS = Automatic with select shift
  • AV = Continuously variable
  • M = Manual
  • 3 - 10 = Number of gears

Fuel type

  • X = Regular gasoline
  • Z = Premium gasoline
  • D = Diesel
  • E = Ethanol (E85)
  • N = Natural gas

Fuel Consumption City and highway fuel consumption ratings are shown in litres per 100 kilometres (L/100 km) - the combined rating (55% city, 45% hwy) is shown in L/100 km and in miles per gallon (mpg)

CO2 Emissions The tailpipe emissions of carbon dioxide (in grams per kilometre) for combined city and highway driving


# Import the pandas and numpy packages
import pandas as pd
import numpy as np

# Load the data
cars = pd.read_csv('data/co2_emissions_canada.csv')

# create numpy arrays
cars_makes = cars['Make'].to_numpy()
cars_models = cars['Model'].to_numpy()
cars_classes = cars['Vehicle Class'].to_numpy()
cars_engine_sizes = cars['Engine Size(L)'].to_numpy()
cars_cylinders = cars['Cylinders'].to_numpy()
cars_transmissions = cars['Transmission'].to_numpy()
cars_fuel_types = cars['Fuel Type'].to_numpy()
cars_fuel_consumption = cars['Fuel Consumption Comb (L/100 km)'].to_numpy()
cars_co2_emissions = cars['CO2 Emissions(g/km)'].to_numpy()

# Preview the dataframe

Exploratory Data Analysis

Look at the first ten items in the CO2 emissions array


1. There are total 42 types of car brand.

2. There are total 2053 unique car model.

3. There are total 16 types of vehicle class basis on their gross vehicle weight rating (GVWR) and volume index.

1. What is the median engine size in liters?

cars['Engine Size(L)'].median()

2. What is the average fuel consumption for regular gasoline (Fuel Type = X), premium gasoline (Z), ethanol (E), and diesel (D)?

cars.groupby(['Fuel Type'])['Fuel Consumption Comb (L/100 km)'].mean()

3. What is the correlation between fuel consumption and CO2 emissions?

  • AI Chat
  • Code