| import streamlit as st |
| import pandas as pd |
| import plotly.express as px |
| import pydeck as pdk |
|
|
| |
| st.title("Driving the Future: Exploring Electric Vehicle Trends") |
| st.markdown("### Authors: Tony An, Nabeel Bashir, Devansh Kumar, Jiajun Li") |
|
|
| |
| data_path = 'data/Electric_Vehicle_Population_Data.csv' |
| ev_data = pd.read_csv(data_path) |
|
|
| |
| 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 = { |
| "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) |
|
|
|
|
| |
| 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') |
|
|
| |
| 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. |
| """) |
|
|
| |
| 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. |
| """) |
|
|
| |
| county_counts = ev_data['County'].value_counts().reset_index() |
| county_counts.columns = ['County', 'Count'] |
|
|
| |
| 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 |
|
|
| |
| county_counts['Color'] = county_counts['County'].apply( |
| lambda x: 'blue' if x == selected_county else 'green' |
| ) |
|
|
| |
| |
| 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"} |
| } |
| )) |
|
|
| |
| 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') |
|
|
| |
| 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) |
|
|
| |
| 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) |
|
|
| |
| 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) |
|
|
| |
| 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. |
| """) |
|
|
| |
| 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. |
| """) |
|
|
| |
| 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) |
| """) |