File size: 12,164 Bytes
61dfc55 979f8ec 4830705 5dd9543 3ddfd7a 61dfc55 64d50ce 61dfc55 4830705 3121baf 61dfc55 4830705 3121baf 61dfc55 94e87ff 979f8ec 94e87ff 3121baf d16d6dd 3121baf 94e87ff 61dfc55 d16d6dd 61dfc55 cb8a883 3121baf cb8a883 5dd9543 61dfc55 5dd9543 61dfc55 5dd9543 61dfc55 5dd9543 4830705 3121baf 61dfc55 94e87ff 3121baf 94e87ff 3121baf 94e87ff 3121baf 61dfc55 3121baf 61dfc55 3121baf 94e87ff 3121baf 61dfc55 3121baf 61dfc55 3121baf 94e87ff 3121baf 94e87ff 61dfc55 94e87ff 61dfc55 3121baf 61dfc55 3121baf 61dfc55 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | import streamlit as st
import pandas as pd
import plotly.express as px
import pydeck as pdk
# Group Members
st.title("Driving the Future: Exploring Electric Vehicle Trends")
st.markdown("### Authors: Tony An, Nabeel Bashir, Devansh Kumar, Jiajun Li")
# Load Data
data_path = 'data/Electric_Vehicle_Population_Data.csv'
ev_data = pd.read_csv(data_path)
# Contextual Data 1 (National Trends: Vehicle Offerings)
contextual_data_1 = {
"Fuel Type": [
"Ethanol (E85)", "CNG (Dedicated and Bi-Fuel)", "Diesel", "Electricity*",
"Hybrid Electric", "Propane (Dedicated and Bi-Fuel)", "Hydrogen", "Methanol (M85)"
],
"1991": [0, 0, 17, 0, 0, 0, 0, 2],
"1992": [1, 2, 14, 0, 0, 0, 0, 2],
"1993": [1, 2, 5, 0, 0, 0, 0, 4],
"1994": [1, 2, 12, 0, 0, 0, 0, 2],
"1995": [0, 10, 13, 1, 0, 0, 0, 2],
"1996": [1, 10, 12, 0, 0, 0, 0, 1],
"1997": [1, 9, 11, 3, 0, 3, 0, 1],
"1998": [2, 12, 11, 8, 0, 3, 0, 0],
"1999": [6, 16, 7, 16, 0, 5, 0, 0],
"2000": [8, 15, 3, 12, 2, 2, 0, 0],
"2001": [11, 16, 3, 10, 2, 5, 0, 0],
"2002": [16, 18, 4, 6, 3, 5, 0, 0],
"2003": [22, 16, 4, 5, 3, 1, 0, 0],
"2004": [19, 16, 7, 1, 3, 1, 0, 0],
"2005": [24, 5, 8, 0, 8, 0, 0, 0],
"2006": [22, 5, 6, 0, 8, 0, 0, 0],
"2007": [31, 1, 7, 0, 11, 0, 0, 0],
"2008": [31, 1, 6, 1, 16, 1, 0, 0],
"2009": [36, 1, 12, 1, 19, 1, 0, 0],
"2010": [34, 1, 14, 1, 20, 0, 0, 0],
"2011": [72, 1, 16, 2, 29, 0, 0, 0],
"2012": [62, 6, 17, 6, 31, 1, 1, 0],
"2013": [84, 11, 22, 15, 38, 6, 1, 0],
"2014": [90, 19, 35, 16, 43, 14, 2, 0],
"2015": [84, 17, 39, 27, 46, 10, 3, 0],
"2016": [66, 12, 29, 29, 31, 5, 3, 0],
"2017": [45, 9, 21, 51, 44, 8, 2, 0],
"2018": [53, 9, 38, 57, 43, 7, 2, 0],
"2019": [40, 7, 30, 72, 64, 7, 4, 0],
"2020": [25, 10, 20, 83, 81, 8, 4, 0],
"2021": [14, 4, 30, 95, 127, 4, 5, 0],
"2022": [17, 0, 29, 132, 149, 0, 5, 0],
"2023": [10, 0, 22, 116, 127, 0, 5, 0],
"2024": [5, 0, 20, 149, 143, 0, 5, 0],
}
contextual_df_1 = pd.DataFrame(contextual_data_1)
# Contextual Data 2 (National Trends: Vehicle Registration Changes)
contextual_data_2 = {
"Fuel Type": ["Gasoline", "Flex Fuel", "Diesel", "Hybrid Electric", "Electric",
"Biodiesel", "PHEV", "Compressed Natural Gas", "Hydrogen",
"Propane", "Bi-Fuel", "Other", "Unspecified"],
"2016-2017": [1.1, 10.0, 4.7, 7.3, 25.9, None, 26.3, -8.8, 59.6, 5.3, None, -0.3, -6.9],
"2017-2018": [0.7, 6.4, 2.0, 4.9, 33.7, None, 25.3, -8.9, 34.1, -58.3, None, -3.9, -4.5],
"2018-2019": [1.0, 4.5, 3.2, 6.0, 26.9, None, 14.0, -8.7, 62.0, -20.0, None, -4.7, -2.4],
"2019-2020": [0.3, 1.6, 3.5, 6.3, 23.1, None, 9.7, -7.5, 9.4, 9.1, None, -5.8, -4.7],
"2020-2021": [3.6, -32.1, -24.6, 12.8, 29.9, None, 21.5, -1037.8, -18.2, 99.9, None, None, None],
"2021-2022": [0.3, -1.4, 0.6, 12.2, 40.3, 13.1, 25.3, -135.0, 20.5, -7.2, None, None, None],
"2022-2023": [-1.5, -10.0, -1.7, 8.7, 21.5, 1.4, 11.5, -16.1, 8.4, -8.9, -43.3, -10.5, None]
}
contextual_df_2 = pd.DataFrame(contextual_data_2)
# Data Preparation
ev_data[['Longitude', 'Latitude']] = ev_data['Vehicle Location'].str.extract(r'POINT \((-?\d+\.\d+) (-?\d+\.\d+)\)')
ev_data['Latitude'] = pd.to_numeric(ev_data['Latitude'], errors='coerce')
ev_data['Longitude'] = pd.to_numeric(ev_data['Longitude'], errors='coerce')
# Introduction Story
st.markdown("""
Electric vehicles (EVs) are at the forefront of a transportation revolution. Once seen as a futuristic concept, EVs are now transforming how we move, reducing emissions, and pushing us toward a more sustainable world. Our project examines the growth of EV adoption, starting with **Washington State** as a case study and connecting it to broader **national trends**.
In this article, we aim to tell the story of **where EVs are being adopted**, **how the number of EV models has surged over time**, and how the **national vehicle landscape** is shifting away from traditional fuels. By examining both regional and national trends, we provide insights that highlight the significance of EVs in reshaping the transportation industry.
The data reveals not just numbers but a powerful narrative about the choices we are making today to shape a cleaner and greener tomorrow.
""")
# Visualization 1: Geographic Distribution
st.subheader("Where Are Electric Vehicles Adopted the Most?")
st.markdown("""
Our journey begins in **Washington State**, a leader in EV adoption. King County, home to Seattle, stands out with more than **107,000 electric vehicles**—a number far ahead of other counties. Urban density, infrastructure readiness, and local policies encouraging sustainability play a significant role here.
This interactive map below lets you explore where EVs are registered across Washington. By selecting different counties, you can see how adoption varies and uncover patterns, such as higher concentrations near metropolitan areas.
""")
# Central Interactive Visualization
county_counts = ev_data['County'].value_counts().reset_index()
county_counts.columns = ['County', 'Count']
# Add interactivity for county selection
selected_county = st.selectbox("Select a County to Filter:", options=["All"] + county_counts['County'].tolist())
if selected_county != "All":
ev_data_filtered = ev_data[ev_data['County'] == selected_county]
else:
ev_data_filtered = ev_data
# Highlight the selected bar
county_counts['Color'] = county_counts['County'].apply(
lambda x: 'blue' if x == selected_county else 'green'
)
# Visualization 1: Map of EV Locations
# st.subheader("Geographic Distribution of EVs")
filtered_data = ev_data_filtered.dropna(subset=['Latitude', 'Longitude'])
st.pydeck_chart(pdk.Deck(
initial_view_state=pdk.ViewState(
latitude=filtered_data['Latitude'].mean(),
longitude=filtered_data['Longitude'].mean(),
zoom=7,
),
layers=[
pdk.Layer(
'ScatterplotLayer',
data=filtered_data,
get_position='[Longitude, Latitude]',
get_radius=200,
get_color='[200, 30, 0, 160]',
pickable=True
)
],
tooltip={
"html": "<b>Make:</b> {Make}<br/><b>Model:</b> {Model}<br/><b>Electric Range:</b> {Electric Range}",
"style": {"backgroundColor": "steelblue", "color": "white"}
}
))
# Visualization 2: Vehicle Model Trends
ev_data['Model Year'] = pd.to_numeric(ev_data['Model Year'], errors='coerce')
model_year_counts = ev_data_filtered['Model Year'].value_counts().reset_index()
model_year_counts.columns = ['Year', 'Count']
model_year_counts = model_year_counts.sort_values('Year')
# Visualization 2: Trend of EV Models
st.subheader("How Have EV Models Evolved Over Time?")
st.markdown("""
The timeline of EV adoption tells a fascinating story. For decades, electric vehicles were rare, with little consumer interest and limited technological capabilities. However, starting in **2010**, things began to change. Policy incentives, growing environmental awareness, and advancements in battery technology triggered a surge in EV models.
This line chart below captures this growth beautifully, showing a **dramatic increase in EV model releases** after 2010. The trend peaks after 2020, reflecting the combined efforts of government policies, private investment, and growing public interest in clean energy transportation.
""")
fig_year = px.line(
model_year_counts,
x='Year',
y='Count',
title="Trend of EV Models Released Over Time",
labels={"Year": "Model Year", "Count": "Number of Models"},
markers=True
)
st.plotly_chart(fig_year, use_container_width=True)
# Visualization 3: National Trends in Vehicle Offerings
st.subheader("How Is the U.S. Vehicle Market Changing?")
st.markdown("""
At the national level, the transformation is equally compelling. This stacked bar chart showcases the number of **light-duty vehicle models** offered by fuel type over time. Notice the rapid growth in **electric vehicles (red)** and **hybrid electric vehicles (green)**, especially in the past two decades.
Meanwhile, traditional fuels such as **diesel** and **CNG** have plateaued or declined. This trend highlights the industry's shift toward cleaner and more efficient energy sources, driven by consumer demand and regulatory pressure.
""")
contextual_melted_1 = pd.melt(contextual_df_1, id_vars=['Fuel Type'], var_name='Year', value_name='Models Offered')
fig_contextual_1 = px.bar(
contextual_melted_1,
x='Year',
y='Models Offered',
color='Fuel Type',
title='National Light-Duty Vehicle Offerings by Fuel Type',
labels={"Year": "Year", "Models Offered": "Number of Models Offered"},
barmode='stack'
)
st.plotly_chart(fig_contextual_1, use_container_width=True)
# Visualization 4: Registration Trends
st.subheader("Are EV Registrations Outpacing Traditional Vehicles?")
st.markdown("""
Finally, let’s examine the **percentage change in vehicle registrations** across fuel types. While gasoline and diesel registrations have stagnated, **electric vehicles** and **plug-in hybrids (PHEVs)** have surged, with growth rates exceeding 20% in recent years.
This line chart shows the transition clearly: traditional vehicles are gradually being replaced by cleaner alternatives. EV adoption is accelerating, and this momentum is expected to continue as technology improves and infrastructure expands.
""")
contextual_melted_2 = pd.melt(contextual_df_2, id_vars=['Fuel Type'], var_name='Year', value_name='Change (%)')
fig_contextual_2 = px.line(
contextual_melted_2,
x='Year',
y='Change (%)',
color='Fuel Type',
title='Change in U.S. Light-Duty Vehicle Registration Counts',
labels={"Year": "Year", "Change (%)": "Percentage Change"}
)
st.plotly_chart(fig_contextual_2, use_container_width=True)
# Comparative Insights
st.subheader("What Did We Learn?")
st.markdown("""
The rise of electric vehicles is reshaping transportation at both the state and national levels. Here’s what we learned:
1. **King County** in Washington leads EV adoption, thanks to strong policies, urban infrastructure, and early investments.
2. **Post-2010 growth** in EV model availability marks a clear turning point, with manufacturers and policymakers prioritizing cleaner transportation solutions.
3. Nationally, EV registrations are growing rapidly, while traditional fuels like gasoline and diesel are showing clear signs of decline.
4. **Hybrids and plug-in hybrids** serve as an essential bridge, easing the transition for consumers toward fully electric vehicles.
This data tells a story of transformation—one where consumer choices, technological advancements, and environmental responsibility intersect to shape the future of transportation.
""")
# Conclusion
st.subheader("Conclusion: Shaping a Sustainable Tomorrow")
st.markdown("""
Electric vehicles are not just a passing trend; they represent a fundamental shift in how we approach transportation, energy consumption, and environmental sustainability. From King County’s dominance in Washington to the surging popularity of EVs across the nation, it’s clear that we are witnessing a significant transformation.
However, the work is far from over. To build on this momentum, we need continued investments in **charging infrastructure**, more **affordable EV options**, and stronger **policy incentives** to make EV adoption accessible to all.
As individuals, we can support this shift by considering EVs for our next vehicle purchase, advocating for sustainable policies, and spreading awareness about the benefits of clean transportation.
Together, we can drive the transition toward a **cleaner, greener, and more sustainable tomorrow**—one electric vehicle at a time.
""")
# Citations
st.markdown("""
### Sources
1. Dataset: [Electric Vehicle Population Data](https://catalog.data.gov/dataset/electric-vehicle-population-data)
2. Contextual Data: [U.S. Light-Duty Vehicle Offerings](https://afdc.energy.gov/data/10303)
3. Contextual Data: [U.S. Vehicle Registration Trends](https://afdc.energy.gov/data/10881)
""") |