0% found this document useful (0 votes)
0 views

ML_Assignment

The document outlines an analysis of electric vehicle (EV) adoption in India for 2023, utilizing datasets on EV sales and traditional vehicle sales. It includes tasks such as visualizing EV sales by state, comparing monthly EV sales with traditional vehicle sales, and identifying trends based on government incentives and charging infrastructure. Key findings include a positive correlation between government incentives and EV sales, as well as insights into the impact of charging stations and speed on EV adoption.

Uploaded by

S.S Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

ML_Assignment

The document outlines an analysis of electric vehicle (EV) adoption in India for 2023, utilizing datasets on EV sales and traditional vehicle sales. It includes tasks such as visualizing EV sales by state, comparing monthly EV sales with traditional vehicle sales, and identifying trends based on government incentives and charging infrastructure. Key findings include a positive correlation between government incentives and EV sales, as well as insights into the impact of charging stations and speed on EV adoption.

Uploaded by

S.S Verma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

In [2]: # Project: Electric Vehicle (EV) Adoption Analysis – India (2023)

import pandas as pd

In [3]: # Loading the CSV file, i.e. the dataset on which we have to perfrom the ana
df = pd.read_csv('India_EV_Sales_2023.csv')
df.head()

Out[3]: Year Month EV_Category Units_Sold Market_Share State Growth

0 2023 January 2W 53972 47.92% Maharashtra 2

1 2023 February 2W 63275 10.55% Maharashtra 1

2 2023 March 2W 62116 58.57% Maharashtra 2

3 2023 April 2W 89269 44.51% Maharashtra 1

4 2023 May 2W 14573 63.19% Maharashtra 4

In [8]: # Task 1: Visualize the increase in EV sales by region (State)


import matplotlib.pyplot as plt
import seaborn as sns

# Group data by State and sum Units_Sold


state_sales = df.groupby('State')['Units_Sold'].sum().sort_values(ascending=

# Bar Plot
plt.figure(figsize=(12, 6))
sns.barplot(x=state_sales.index, y=state_sales.values, hue=state_sales.index
plt.xticks(rotation=45)
plt.title('Total EV Sales by State (2023)')
plt.ylabel('Units Sold')
plt.xlabel('State')
plt.tight_layout()
plt.show()
In [16]: # Task 2: Compare EV sales with traditional vehicle sales
import pandas as pd
import matplotlib.pyplot as plt

# Load the EV sales dataset


ev_df = pd.read_csv('India_EV_Sales_2023.csv')

# Load the traditional vehicle sales dataset


traditional_df = pd.read_csv('Traditional_Vehicle_Sales.csv')

# Ensure the 'Month' and 'State' columns match for merging


ev_df['Month'] = ev_df['Month'].str.capitalize() # Capitalize months for co
traditional_df['Month'] = traditional_df['Month'].str.capitalize()

# Merge the two datasets on 'State' and 'Month'


merged_df = pd.merge(ev_df, traditional_df, on=['State', 'Month'], how='inne

# Compare EV sales vs Traditional vehicle sales (monthly comparison)


merged_df['Units_Sold_Traditional'] = merged_df['Units Sold (Traditional)']
merged_df['Units_Sold_EV'] = merged_df['Units_Sold']

# Summing sales per month


monthly_sales_comparison = merged_df.groupby('Month')[['Units_Sold_EV', 'Uni

# Plot the comparison as a bar chart


monthly_sales_comparison.plot(kind='bar', figsize=(12, 6))
plt.title('Monthly EV Sales vs Traditional Vehicle Sales (2023)')
plt.ylabel('Units Sold')
plt.xlabel('Month')
plt.xticks(rotation=45)
plt.tight_layout()

# Display the plot


plt.show()

In [18]: # Task 3: Identify trends based on government incentives or infrastructure


import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Load the dataset


df = pd.read_csv('Consumer_Adoption.csv')

# Display the first few rows of the dataset to understand its structure
print(df.head())

# Check for any missing values and handle them


print(df.isnull().sum())
df = df.dropna() # Dropping rows with missing data, or you could fillna() b

# Convert columns like 'Govt Incentive Amount' and 'EV Units Sold' to numeri
df['Govt Incentive Amount'] = df['Govt Incentive Amount'].str.replace(' INR'
df['EV Units Sold'] = df['EV Units Sold'].astype(int)

# Calculate correlation between government incentive and EV sales to see the


correlation = df['Govt Incentive Amount'].corr(df['EV Units Sold'])
print(f"Correlation between Government Incentives and EV Sales: {correlation

# Visualize the trend: Plotting EV sales vs. government incentive amount


plt.figure(figsize=(10, 6))
sns.scatterplot(x='Govt Incentive Amount', y='EV Units Sold', data=df)
plt.title('EV Units Sold vs. Govt Incentive Amount')
plt.xlabel('Government Incentive Amount (INR)')
plt.ylabel('EV Units Sold')
plt.show()

# Analyze trends based on Charging Stations and Speed


charging_trend = df.groupby('Charging Speed')['EV Units Sold'].mean().reset_

# Plot the trend of EV units sold by charging speed


plt.figure(figsize=(10, 6))
sns.barplot(x='Charging Speed', y='EV Units Sold', data=charging_trend)
plt.title('EV Units Sold by Charging Speed')
plt.xlabel('Charging Speed Type')
plt.ylabel('Average EV Units Sold')
plt.show()

# Trend analysis based on Charging Stations available


charging_station_trend = df.groupby('Charging Stations')['EV Units Sold'].me

# Plot the trend of EV units sold by the number of charging stations


plt.figure(figsize=(10, 6))
sns.lineplot(x='Charging Stations', y='EV Units Sold', data=charging_station
plt.title('EV Units Sold vs. Number of Charging Stations')
plt.xlabel('Number of Charging Stations')
plt.ylabel('Average EV Units Sold')
plt.show()
State Month EV Units Sold Govt Incentive Amount \
0 Tamil Nadu January 53972 50000 INR
1 Karnataka February 63275 60000 INR
2 Gujarat March 62116 40000 INR
3 Maharashtra April 89269 70000 INR
4 West Bengal May 14573 45000 INR

Charging Stations Charging Speed Total Vehicle Sales EV Market Share


0 150 Fast Charging 350000 15%
1 120 Regular Charging 280000 22%
2 100 Fast Charging 320000 19%
3 200 Fast Charging 450000 25%
4 80 Regular Charging 240000 6%
State 0
Month 0
EV Units Sold 0
Govt Incentive Amount 0
Charging Stations 0
Charging Speed 0
Total Vehicle Sales 0
EV Market Share 0
dtype: int64
Correlation between Government Incentives and EV Sales: 0.668730081030836
This notebook was converted with convert.ploomber.io

You might also like