├── Python.py └── README.md /Python.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import numpy as np 3 | import matplotlib.pyplot as plt 4 | import seaborn as sns 5 | 6 | # --------------------------------------------- 7 | # Load the dataset 8 | # --------------------------------------------- 9 | df = pd.read_csv("C:\\Users\\Saksham\\Downloads\\cleaned_electric_vehicle_data ###.csv") 10 | 11 | # --------------------------------------------- 12 | # Basic Data Inspection 13 | # --------------------------------------------- 14 | print("\nDataset Info:") 15 | print(df.info()) 16 | 17 | print("\nSummary Statistics:") 18 | print(df.describe(include='all')) # Removed datetime_is_numeric for compatibility 19 | 20 | print("\nMissing Values in Each Column:") 21 | print(df.isnull().sum()) 22 | 23 | # --------------------------------------------- 24 | # Set the visual style 25 | # --------------------------------------------- 26 | sns.set(style="whitegrid") 27 | 28 | # --------------------------------------------- 29 | # Objective 1: Distribution of Electric Vehicle Types 30 | # --------------------------------------------- 31 | plt.figure(figsize=(10, 6)) 32 | sns.countplot( 33 | data=df, 34 | y='clean_alternative_fuel_vehicle_type', 35 | order=df['clean_alternative_fuel_vehicle_type'].value_counts().index, 36 | palette='viridis' 37 | ) 38 | plt.title('Distribution of Electric Vehicle Types') 39 | plt.xlabel('Count') 40 | plt.ylabel('Vehicle Type') 41 | plt.tight_layout() 42 | plt.show() 43 | 44 | # Donut Chart 45 | vehicle_type_counts = df['clean_alternative_fuel_vehicle_type'].value_counts() 46 | plt.figure(figsize=(8, 8)) 47 | colors = sns.color_palette('viridis', len(vehicle_type_counts)) 48 | plt.pie( 49 | vehicle_type_counts, 50 | labels=vehicle_type_counts.index, 51 | colors=colors, 52 | wedgeprops=dict(width=0.4), 53 | startangle=140, 54 | autopct='%1.1f%%' 55 | ) 56 | plt.title('EV Type Distribution (Donut Chart)') 57 | plt.tight_layout() 58 | plt.show() 59 | 60 | # --------------------------------------------- 61 | # Objective 2: Top 10 EV Makes by Count 62 | # --------------------------------------------- 63 | top_makes = df['make'].value_counts().nlargest(10) 64 | 65 | plt.figure(figsize=(10, 6)) 66 | sns.barplot(x=top_makes.values, y=top_makes.index, palette='crest') 67 | plt.title('Top 10 EV Makes by Count') 68 | plt.xlabel('Number of Vehicles') 69 | plt.ylabel('EV Make') 70 | plt.tight_layout() 71 | plt.show() 72 | 73 | # --------------------------------------------- 74 | # Objective 3: Electric Range Distribution 75 | # --------------------------------------------- 76 | plt.figure(figsize=(10, 6)) 77 | sns.histplot(df['electric_range'], bins=50, kde=True, color='skyblue') 78 | plt.title('Electric Range Distribution') 79 | plt.xlabel('Electric Range (miles)') 80 | plt.ylabel('Frequency') 81 | plt.tight_layout() 82 | plt.show() 83 | 84 | # --------------------------------------------- 85 | # Objective 4: EV Registration Trend by Year 86 | # --------------------------------------------- 87 | plt.figure(figsize=(10, 6)) 88 | sns.countplot(data=df, x='model_year', palette='flare') 89 | plt.title('EV Registration Trend by Year') 90 | plt.xlabel('Model Year') 91 | plt.ylabel('Number of Registrations') 92 | plt.xticks(rotation=45) 93 | plt.tight_layout() 94 | plt.show() 95 | 96 | # --------------------------------------------- 97 | # Objective 5: Top Cities with the Most EV Registration 98 | # --------------------------------------------- 99 | top_cities = df['city'].value_counts().nlargest(10) 100 | 101 | plt.figure(figsize=(10, 6)) 102 | sns.barplot(x=top_cities.values, y=top_cities.index, palette='magma') 103 | plt.title('Top Cities with the Most EV Registration') 104 | plt.xlabel('Number of Registrations') 105 | plt.ylabel('City') 106 | plt.tight_layout() 107 | plt.show() 108 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | uighdw 2 | int main 3 | char a 4 | int abc 5 | . 6 | int 7 | aa 8 | --------------------------------------------------------------------------------