Business Task

The primary objective of this project is to Analyze the popularity of different EV types (e.g., BEVs, PHEVs) to tailor marketing and product strategies.

About Data

This dataset shows the Battery Electric Vehicles (BEVs) and Plug-in Hybrid Electric Vehicles (PHEVs) that are currently registered through Washington State Department of Licensing (DOL). The Data was downloaded in csv format, click here to download the dataset.

Load Packages

These packages are necessary for the SQL queries to run on R Markdown

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(DBI)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ readr     2.1.4
## ✔ ggplot2   3.4.3     ✔ stringr   1.5.0
## ✔ lubridate 1.9.2     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(bigrquery)
bq_auth(path = "C:\\Users\\ARTHUR\\OneDrive\\Documents\\my_service_account_key.json")

Establish a Connection

Establish a connection between the R Markdown document and BigQuery.

con <- dbConnect(
  bigrquery::bigquery(),
  project = "sharp-messenger-396703"
)

Data Preparation

SELECT *
FROM `sharp-messenger-396703.washington_electric_car.Electric_Vehicles`
LIMIT 10
Displaying records 1 - 10
VIN_1_10 County City State Postal_Code Model_Year Make Model Electric_Vehicle_Type Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility Electric_Range Base_MSRP Legislative_District DOL_Vehicle_ID Vehicle_Location Electric_Utility _2020_Census_Tract
3FA6P0PU4D Spokane Spokane WA 99207 2013 FORD FUSION Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 19 0 3 175243848 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
3FA6P0SU2E Spokane Spokane WA 99207 2014 FORD FUSION Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 19 0 3 196204053 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
1C4JJXR60N Spokane Spokane WA 99207 2022 JEEP WRANGLER Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 22 0 3 204662489 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
JTDKARFP1H Spokane Spokane WA 99207 2017 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 3 181736264 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
JTDKN3DP5F Spokane Spokane WA 99207 2015 TOYOTA PRIUS PLUG-IN Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 6 0 3 257412284 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
JTDKARFPXJ Lewis Chehalis WA 98532 2018 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 20 474803262 POINT (-122.96692 46.66113) PUGET SOUND ENERGY INC||CITY OF TACOMA - (WA) NA
JTDKARFPXJ Lewis Chehalis WA 98532 2018 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 20 147852729 POINT (-122.96692 46.66113) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
5LMTJ5DZ3P Lewis Onalaska WA 98570 2023 LINCOLN CORSAIR Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 28 0 20 251422783 POINT (-122.71921 46.577) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
JTDKARFP9J Lewis Onalaska WA 98570 2018 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 20 178742357 POINT (-122.71921 46.577) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
3FA6P0PUXG Lewis Chehalis WA 98532 2016 FORD FUSION Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 19 0 20 256912239 POINT (-122.96692 46.66113) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA

Data Cleaning

Because of BigQuery restrictions to manipulate table for sandbox users, I created another table and also cleaned the data in the process of creating the new table of my analysis. I filtered the dataset to ensure that the analysis is based on relevant, consistent, and accurate data. Key steps in data cleaning include::

SELECT *
FROM `sharp-messenger-396703.washington_electric_car.Electric_Cars`
LIMIT 10
Displaying records 1 - 10
VIN_1_10 County City State Postal_Code Model_Year Make Model Electric_Vehicle_Type Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility Electric_Range Base_MSRP Legislative_District DOL_Vehicle_ID Vehicle_Location Electric_Utility _2020_Census_Tract
3FA6P0PU4D Spokane Spokane WA 99207 2013 FORD FUSION Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 19 0 3 175243848 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
1C4JJXR60N Spokane Spokane WA 99207 2022 JEEP WRANGLER Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 22 0 3 204662489 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
JTDKN3DP5F Spokane Spokane WA 99207 2015 TOYOTA PRIUS PLUG-IN Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 6 0 3 257412284 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
JTDKARFP1H Spokane Spokane WA 99207 2017 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 3 181736264 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
3FA6P0SU2E Spokane Spokane WA 99207 2014 FORD FUSION Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 19 0 3 196204053 POINT (-117.39787 47.67936) MODERN ELECTRIC WATER COMPANY NA
JTDKARFP9J Lewis Onalaska WA 98570 2018 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 20 178742357 POINT (-122.71921 46.577) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
JTDKARFPXJ Lewis Chehalis WA 98532 2018 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 20 147852729 POINT (-122.96692 46.66113) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
1C4JJXR65M Lewis Onalaska WA 98570 2021 JEEP WRANGLER Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 21 0 20 214771882 POINT (-122.71921 46.577) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
5LMTJ5DZ3P Lewis Onalaska WA 98570 2023 LINCOLN CORSAIR Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 28 0 20 251422783 POINT (-122.71921 46.577) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA
JTDKARFP1J Lewis Ethel WA 98542 2018 TOYOTA PRIUS PRIME Plug-in Hybrid Electric Vehicle (PHEV) Not eligible due to low battery range 25 0 20 268398518 POINT (-122.71614 46.5308781) BONNEVILLE POWER ADMINISTRATION||CITY OF TACOMA - (WA)||PUD NO 1 OF LEWIS COUNTY NA

Data Analysis

SELECT 
  COUNT(VIN__1_10_) AS Total_Vehicle,
  COUNT(DISTINCT Electric_Utility) AS Charging_Station
FROM 
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
1 records
Total_Vehicle Charging_Station
153491 75

This analysis revealed that there 153491 electric vehicles and 75 charging stations in Washington

SELECT 
  Electric_Vehicle_Type,
  COUNT(VIN__1_10_) AS Total_Electric_Cars
FROM 
  sharp-messenger-396703.washington_electric_car.Electric_Cars
GROUP BY
  Electric_Vehicle_Type
2 records
Electric_Vehicle_Type Total_Electric_Cars
Plug-in Hybrid Electric Vehicle (PHEV) 34315
Battery Electric Vehicle (BEV) 119176

The two types are: Plug-in Hybrid Electric Vehicle (PHEV) and Battery Electric Vehicle (BEV). It occurred that consumer prefer Battery Electric Vehicle (119176) over Plug-in Hybrid Electric Vehicle (34315).

SELECT
  Electric_Vehicle_Type,
  SUM(CASE WHEN Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility = 'Clean Alternative Fuel Vehicle Eligible' THEN 1 ELSE 0 END) AS Total_Eligible_Cars,
  SUM(CASE WHEN Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility = 'Not eligible due to low battery range' THEN 1 ELSE 0 END) AS Total_Non_Eligible_Cars,
  SUM(CASE WHEN Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility = 'Eligibility unknown as battery range has not been researched' THEN 1 ELSE 0 END) AS Total_Eligibility_Unknown
FROM 
  sharp-messenger-396703.washington_electric_car.Electric_Cars
GROUP BY
  Electric_Vehicle_Type
2 records
Electric_Vehicle_Type Total_Eligible_Cars Total_Non_Eligible_Cars Total_Eligibility_Unknown
Plug-in Hybrid Electric Vehicle (PHEV) 16302 18013 0
Battery Electric Vehicle (BEV) 46427 9 72740

The Battery Electric Vehicle (46427) appears to have a higher number of vehicles eligible to use fuel as an alternative, while Plug-in Hybrid Electric Vehicle (16302) are eligible to use fuel as an alternative. This is one of the reason why consumers preferred Battery Electric Vehicle over Plug-in Hybrid Electric Vehicle

SELECT
  COUNT(DISTINCT Make) AS Total_Vehicle_Makers,
  COUNT(DISTINCT Model) AS Total_Vehicle_Models
FROM 
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
1 records
Total_Vehicle_Makers Total_Vehicle_Models
37 127

There are 37 Electric Vehicle Makers and 127 Models in washington, which leaves the consumers with a wide range of option to choose.

SELECT
  Electric_Vehicle_Type,
  COUNT(DISTINCT Make) AS Total_Vehicle_Makers,
  COUNT(DISTINCT Model) AS Total_Vehicle_Models
FROM 
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
GROUP BY
  Electric_Vehicle_Type
2 records
Electric_Vehicle_Type Total_Vehicle_Makers Total_Vehicle_Models
Plug-in Hybrid Electric Vehicle (PHEV) 25 62
Battery Electric Vehicle (BEV) 27 68

I discovered that out of 37 Electric Vehicle Makers in Washington, 27 Electric Vehicle Makers make only Battery Electric Vehicle with 68 Models, while 25 Electric Vehicle Makers make only Plug-in Hybrid Electric Vehicle with 60 Models. The Makers of Electric Vehicles seems to prefer producing Battery Electric Vehicle over Plug-in Hybrid Electric Vehicle because of consumer preferences which is Battery Electric Vehicle due to most of them being eligible to use fuel as an alternative.

Further analysis showed some Make that produce both Battery Electric Vehicle and Plug-in Hybrid Electric Vehicle and the number of each vehicle that they produce.

SELECT
  Make,
  COUNT(DISTINCT CASE WHEN Electric_Vehicle_Type = "Battery Electric Vehicle (BEV)" THEN Model ELSE NULL END) AS BEV_Models,
  COUNT(DISTINCT CASE WHEN Electric_Vehicle_Type = "Plug-in Hybrid Electric Vehicle (PHEV)" THEN Model ELSE NULL END) AS PHEV_Models
FROM
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
WHERE
  Electric_Vehicle_Type IN ("Battery Electric Vehicle (BEV)", "Plug-in Hybrid Electric Vehicle (PHEV)")
GROUP BY
  Make
HAVING
  BEV_Models > 0
  AND PHEV_Models > 0
Displaying records 1 - 10
Make BEV_Models PHEV_Models
FORD 5 3
TOYOTA 2 4
MITSUBISHI 1 1
BMW 4 9
AUDI 6 5
MERCEDES-BENZ 6 4
KIA 4 4
HYUNDAI 5 4
VOLVO 2 5
SUBARU 1 1
SELECT
  COUNT(DISTINCT County) AS Total_Counties,
  COUNT(DISTINCT City) AS Total_Cities
FROM
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
1 records
Total_Counties Total_Cities
40 462

This analysis showed that there are 40 counties and 462 cities in Washington.

SELECT
  Electric_Vehicle_Type,
  COUNT(DISTINCT County) AS Total_EV_County,
  COUNT(DISTINCT City) AS Total_EV_City
FROM
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
GROUP BY
  Electric_Vehicle_Type
ORDER BY 
  Total_EV_County DESC
2 records
Electric_Vehicle_Type Total_EV_County Total_EV_City
Battery Electric Vehicle (BEV) 39 439
Plug-in Hybrid Electric Vehicle (PHEV) 38 398

The resulted showed that out of 40 Counties and 462 Cities in Washington, Battery Electric Vehicles are available in 39 counties and 439 cities, while Plug-in Hybrid Electric Vehicles are available in 38 counties and 398 cities. Further analysis will show the counties with only one Electric Vehicle

WITH CountyEVTypes AS (
  SELECT
    County,
    ARRAY_AGG(DISTINCT Electric_Vehicle_Type) AS EVTypes
  FROM
    `sharp-messenger-396703.washington_electric_car.Electric_Cars`
  GROUP BY
    County
)

SELECT
  County,
  CASE
    WHEN ARRAY_LENGTH(EVTypes) = 2 THEN EVTypes
    ELSE [EVTypes[OFFSET(0)]]
  END AS Electric_Vehicle_Types
FROM CountyEVTypes
Displaying records 1 - 10
County Electric_Vehicle_Types
Spokane Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Lewis Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Clark Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
King Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Grant Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Pierce Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Kitsap Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Benton Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Cowlitz Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)
Grays Harbor Plug-in Hybrid Electric Vehicle (PHEV), Battery Electric Vehicle (BEV)

This analysis returned the electric vehicles that are available in each county. I realized there are 3 counties that has only one type of Electric Vehicles: Columbia and Anchorage have only Battery Electric Vehicles, while county like Garfield has only Plug-in Hybrid Electric Vehicle.

WITH CountyEVTypes AS (
  SELECT
    County,
    ARRAY_AGG(DISTINCT Electric_Vehicle_Type) AS EVTypes
  FROM
    `sharp-messenger-396703.washington_electric_car.Electric_Cars`
  GROUP BY
    County
)

SELECT
  County,
  CASE
    WHEN ARRAY_LENGTH(EVTypes) = 2 THEN EVTypes
    ELSE [EVTypes[OFFSET(0)]]
  END AS Electric_Vehicle_Types
FROM CountyEVTypes
WHERE 
ARRAY_LENGTH(EVTypes) = 1
3 records
County Electric_Vehicle_Types
Garfield Plug-in Hybrid Electric Vehicle (PHEV)
Columbia Battery Electric Vehicle (BEV)
Anchorage Battery Electric Vehicle (BEV)
SELECT
  County,
  Electric_Vehicle_Type,
  COUNT(*) AS Electric_Vehicle_Type_Count
FROM
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
GROUP BY
  County, Electric_Vehicle_Type 
ORDER BY 
  Electric_Vehicle_Type_Count DESC
Displaying records 1 - 10
County Electric_Vehicle_Type Electric_Vehicle_Type_Count
King Battery Electric Vehicle (BEV) 64856
King Plug-in Hybrid Electric Vehicle (PHEV) 15781
Snohomish Battery Electric Vehicle (BEV) 14466
Pierce Battery Electric Vehicle (BEV) 8819
Clark Battery Electric Vehicle (BEV) 6589
Thurston Battery Electric Vehicle (BEV) 4023
Kitsap Battery Electric Vehicle (BEV) 3705
Snohomish Plug-in Hybrid Electric Vehicle (PHEV) 3261
Pierce Plug-in Hybrid Electric Vehicle (PHEV) 2985
Whatcom Battery Electric Vehicle (BEV) 2790

It appeared that the county named King has the highest number of electric vehicles in Washington followed by Snohomish and Pierce

WITH CountyChargingCounts AS (
  SELECT
    County,
    COUNT(DISTINCT Electric_Utility) AS Total_Charging_Station
  FROM
    `sharp-messenger-396703.washington_electric_car.Electric_Cars`
  GROUP BY
    County
)
SELECT
  County,
  Total_Charging_Station
FROM CountyChargingCounts
ORDER BY
  Total_Charging_Station DESC
Displaying records 1 - 10
County Total_Charging_Station
Pierce 13
King 8
Spokane 7
Stevens 5
Whatcom 4
Jefferson 4
Franklin 4
Okanogan 4
Lewis 3
Clark 3

This analysis showed that the county with the highest charging station is Pierce with 13 being the total number of charging station there, Despite having 8819 BEVs and 2985 PHEVs . It was followed by county named King which has charging stations 8, despite having 64856 BEVs and 15781 PHEVs. This result showed that lack of charging station is among the reason for the preferences of Battery Electric Vehicles over Plug-in Hybrid Electric Vehicle

SELECT
  Electric_Vehicle_Type,
  SUM(CASE WHEN Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility = "Clean Alternative Fuel Vehicle Eligible" THEN Electric_Range ELSE 0 END) AS Electric_Range_Sum,
  SUM(CASE WHEN Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility = "'Eligibility unknown as battery range has not been researched'" THEN Electric_Range ELSE 0 END) AS Unknown_Range_Sum,
  SUM(CASE WHEN Clean_Alternative_Fuel_Vehicle__CAFV__Eligibility = "Not eligible due to low battery range" THEN Electric_Range ELSE 0 END) AS Not_Eligible_Range_Sum
FROM 
  `sharp-messenger-396703.washington_electric_car.Electric_Cars`
GROUP BY 
  Electric_Vehicle_Type
2 records
Electric_Vehicle_Type Electric_Range_Sum Unknown_Range_Sum Not_Eligible_Range_Sum
Plug-in Hybrid Electric Vehicle (PHEV) 694962 0 357917
Battery Electric Vehicle (BEV) 9033673 0 261

It was observed that the sum of range per charge of the Battery Electric Vehicle (9033673) was higher than that of Plug-in Hybrid Electric Vehicle (694962) which are eligible to use fuel as an alternative, while the range of those that are not eligible are 261 and 357917 for Battery Electric Vehicle and Plug-in Hybrid Electric Vehicle respectively. This further shows that consumers also preferred the Battery Electric Vehicles due to their long range per charge too.

Recommendations:

Based on the analysis of electric vehicles in Washington, the following recommendations can be made to tailor marketing and product strategies:

  1. Promote Charging Infrastructure: Given the preference for Battery Electric Vehicles (BEVs) over Plug-in Hybrid Electric Vehicles (PHEVs), it’s crucial to invest in and promote the expansion of charging infrastructure. Providing more charging stations can encourage PHEV adoption and alleviate range anxiety.

  2. Educate Consumers: Consumer preferences are influenced by factors such as eligibility for alternative fuels. Manufacturers and policymakers should educate consumers about the benefits of PHEVs and their eligibility for alternative fuels, as this can make PHEVs more attractive.

  3. Diversify Electric Vehicle Models: With a wide variety of electric vehicle makers and models available, manufacturers should continue to diversify their offerings. Offering a broad range of options can cater to different consumer needs and preferences.

  4. Analyze Charging Station Distribution: Analyze the distribution of charging stations in counties with a high number of electric vehicles, such as Pierce and King. Consider expanding charging infrastructure in these counties to further promote electric vehicle adoption.

  5. Monitor Electric Range Improvements: Continue monitoring and improving the electric range of electric vehicles, especially for PHEVs. Longer electric ranges can make PHEVs more competitive and appealing to consumers.

  6. Regional Marketing: Tailor marketing strategies to specific regions in Washington based on the popularity of BEVs and PHEVs. Highlight the advantages of each type of electric vehicle to cater to regional preferences.

  7. Collaboration with Utility Companies: Collaborate with utility companies to enhance the charging infrastructure. Promote partnerships that make charging more accessible and affordable.

  8. County-Level Targeting: For marketing campaigns, consider targeting counties with specific preferences. For example, target Pierce County with PHEV promotions to leverage the existing charging infrastructure.

  9. Incentives and Rebates: Work with policymakers to provide incentives and rebates that encourage PHEV adoption, such as reduced registration fees, tax credits, or other financial incentives.

  10. Research and Development: Invest in research and development to enhance the electric range of PHEVs. Improving the range can bridge the gap between PHEVs and BEVs in consumer preferences.

These recommendations aim to capitalize on consumer preferences while addressing the factors that influence the popularity of different electric vehicle types. Tailoring marketing and product strategies based on these insights can drive electric vehicle adoption and support a sustainable future for transportation in Washington.