Giter Club home page Giter Club logo

electricity-usage-analysis's Introduction

Electricity Usage Analysis

Python Pandas Logo

Key Objectives

  1. Prep the data
  2. Visualize the consumption over time (can be changed monthly, yearly etc.)
  3. Look for daily trends through out the day
  4. Look for trends throughout the week
  5. Give insight into how much energy needs to be accounted for

Process and Code

View Full Python Code File --> Click Me


  1. Prepped the data by importing pandas and adding in additional columns:

power_cols = ["Datetime", "PowerConsumption_Zone1", "PowerConsumption_Zone2", "PowerConsumption_Zone3"]

powerconsumption = pd.read_csv(
    "powerconsumption.csv",
    usecols=power_cols,
    parse_dates=["Datetime"]
).assign(total_consumption = lambda x: x["PowerConsumption_Zone1"] + x["PowerConsumption_Zone2"] + x["PowerConsumption_Zone3"],
         hour = lambda x: x["Datetime"].dt.hour,
         day_of_week = lambda x: x["Datetime"].dt.dayofweek
)

  • We also created a day of the week list and column that we use later for analysis:
day_of_week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"]

powerconsumption["day_name"] = pd.Categorical(powerconsumption["Datetime"].dt.day_name(), categories=day_of_week)

  1. Created an area line chart to show the electricity consumption throughout a month. The variable can easily be changed to show other months:
import seaborn as sns

(powerconsumption
 .set_index(["Datetime"])
 .resample("H")
 .mean()
 .loc["2017-01", ["PowerConsumption_Zone1", "PowerConsumption_Zone2", "PowerConsumption_Zone3"]]
 .plot
 .area(
     title="Hourly Eclectricity Consumption by Zone - Jan 2017",
     xlabel="Date",
     ylabel="Consumption (KwH)"
 )
)


sns.despine()

Chart:
Electrical consumption line area

  1. Create a heatmap to show weekly/hourly trends:
sns.heatmap(
    powerconsumption.pivot_table(
        index="day_name",
        columns="hour",
        values="total_consumption",
        aggfunc="mean"
    ),
    cbar=None,
    cmap="viridis"
).set(title="Power Consumption by Day of Week and Hour",
     ylabel="Day of Week",
     xlabel="Hour");

Heatmap:

Electrical consumption heatmap

Analysis

  • Based off of objectives 3 and 4 we are able to gain insight with our visuals. We see that energy consumption is heavy in early day time but drops off.
  • Most of the days tend to be a similar story, but starting Friday going into the weekend we start to see larger energy consumptions early in the day.
  • We'd also see from our area line chart, we need to keep the committee informed that they need to be able to handle at least 100,000 KwH at any given time.

electricity-usage-analysis's People

Contributors

nmowens95 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.