Skip to content
Project: Analyzing Electric Vehicle Charging Habits
  • AI Chat
  • Code
  • Report
  • As electronic vehicles (EVs) become more popular, there is an increasing need for access to charging stations, also known as ports. To that end, many modern apartment buildings have begun retrofitting their parking garages to include shared charging stations. A charging station is shared if it is accessible by anyone in the building.

    But with increasing demand comes competition for these ports — nothing is more frustrating than coming home to find no charging stations available! In this project, you will use a dataset to help apartment building managers better understand their tenants’ EV charging habits.

    The data has been loaded into a PostgreSQL database with a table named charging_sessions with the following columns:

    charging_sessions

    ColumnDefinitionData type
    garage_idIdentifier for the garage/buildingVARCHAR
    user_idIdentifier for the individual userVARCHAR
    user_typeIndicating whether the station is Shared or PrivateVARCHAR
    start_pluginThe date and time the session startedDATETIME
    start_plugin_hourThe hour (in military time) that the session startedNUMERIC
    end_plugoutThe date and time the session endedDATETIME
    end_plugout_hourThe hour (in military time) that the session endedNUMERIC
    duration_hoursThe length of the session, in hoursNUMERIC
    el_kwhAmount of electricity used (in Kilowatt hours)NUMERIC
    month_pluginThe month that the session startedVARCHAR
    weekdays_pluginThe day of the week that the session startedVARCHAR

    Let’s get started!

    Sources
    • Data: CC BY 4.0, via Kaggle,
    • Image: Julian Herzog, CC BY 4.0, via Wikimedia Commons
    Spinner
    DataFrameavailable as
    unique_users_per_garage
    variable
    -- unique_users_per_garage
    -- Modify the code below
    with unique_users_per_garage as (
    SELECT garage_id, count(distinct user_id) as num_unique_users
    FROM charging_sessions
    where user_type = 'Shared'
    group by garage_id
    order by num_unique_users desc)
    
    select * 
    from unique_users_per_garage;
    Spinner
    DataFrameavailable as
    most_popular_shared_start_times
    variable
    -- most_popular_shared_start_times
    with most_popular_shared_start_times as 
    (select weekdays_plugin, start_plugin_hour, count(user_id) as num_charging_sessions
    from charging_sessions
    where user_type = 'Shared'
    group by weekdays_plugin, start_plugin_hour
    order by num_charging_sessions desc)
    
    select * 
    from most_popular_shared_start_times
    limit 10;
    
    Spinner
    DataFrameavailable as
    long_duration_shared_users
    variable
    -- long_duration_shared_users
    with long_duration_shared_users as (
    select user_id, avg(duration_hours) as avg_charging_duration
    from public.charging_sessions
    where user_type = 'Shared'
    group by user_id
    having avg(duration_hours) > 10
    order by avg_charging_duration desc)
    
    
    select *
    from long_duration_shared_users;