Electric Vehicle Population
The electric vehicle (EV) population in the United States has seen remarkable growth over recent years, as reflected in real-world registration data. By analyzing the Electric_Vehicle_Population_Data.csv, it’s clear that EV adoption has accelerated significantly across key states and cities. This surge is fueled by advancements in battery technology, attractive federal and state incentives, increased consumer environmental awareness, and the rapidly falling costs of EVs. Despite this momentum, challenges remain — particularly around expanding reliable charging infrastructure, improving electric grid capacity, and developing effective battery recycling systems. Addressing these hurdles will be critical to sustaining the future of electric mobility in America.
SELECT * FROM 'Electric_Vehicle_Population_Data.csv';import pandas as pd
from sqlalchemy import create_engine
# Load the CSV file
df_ev = pd.read_csv('Electric_Vehicle_Population_Data.csv')
# Connect to a SQLite database
engine = create_engine('sqlite:///ev_database.db')
# Save DataFrame to database
df_ev.to_sql('electric_vehicle_population', con=engine, if_exists='replace', index=False)
print('✅ Dataset loaded into SQL database successfully!')
# Preview the dataset
df_ev.head()
1. Total EVs Registered Per Year (SQL + Python)
SELECT "Model Year" AS model_year, COUNT(*) AS total_evs
FROM 'Electric_Vehicle_Population_Data.csv'
GROUP BY "Model Year"
ORDER BY "Model Year";import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
# Load the CSV file
df_ev = pd.read_csv('Electric_Vehicle_Population_Data.csv')
# Aggregate the data to get total EVs registered per year
df_yearly = df_ev.groupby('Model Year').size().reset_index(name='total_evs')
# Plot the data
plt.figure(figsize=(10,6))
sns.lineplot(data=df_yearly, x='Model Year', y='total_evs', marker='o')
plt.title('Total Electric Vehicles Registered Per Year', fontsize=16)
plt.xlabel('Model Year')
plt.ylabel('Number of EVs')
plt.grid(True)
plt.show()Top 10 Most Popular EV Models
SELECT "Model", COUNT(*) AS model_count
FROM "Electric_Vehicle_Population_Data.csv"
GROUP BY "Model"
ORDER BY model_count DESC
LIMIT 10;import pandas as pd
# Load the data from the CSV file
df_ev = pd.read_csv('Electric_Vehicle_Population_Data.csv')
# Calculate the top 10 most popular EV models
df_top_models = df_ev.groupby('Model').size().reset_index(name='model_count').sort_values(by='model_count', ascending=False).head(10)
# Plot the data
plt.figure(figsize=(10,6))
sns.barplot(data=df_top_models, y='Model', x='model_count', palette='coolwarm')
plt.title('Top 10 Electric Vehicle Models', fontsize=16)
plt.xlabel('Number of Vehicles')
plt.ylabel('Model')
plt.show()EV Type Breakdown Per Year
SELECT "Model Year", "Electric Vehicle Type", COUNT(*) AS count_type
FROM "Electric_Vehicle_Population_Data.csv"
GROUP BY "Model Year", "Electric Vehicle Type"
ORDER BY "Model Year", "Electric Vehicle Type";import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Load the data from the CSV file
df_ev = pd.read_csv("Electric_Vehicle_Population_Data.csv")
# Group by Model Year and Electric Vehicle Type, and count the number of vehicles
df_ev_type = df_ev.groupby(["Model Year", "Electric Vehicle Type"]).size().reset_index(name='count_type')
# Plot the data
plt.figure(figsize=(14,8))
sns.barplot(data=df_ev_type, x='Model Year', y='count_type', hue='Electric Vehicle Type')
plt.title('EV Type Distribution Over Years', fontsize=16)
plt.xlabel('Model Year')
plt.ylabel('Number of Vehicles')
plt.legend(title='EV Type')
plt.show() df_ev_type.head()