Hourly Energy Consumption¶
Step 1:¶
Import Library¶
In [11]:
import pandas as pd
import numpy as np
import seaborn as sns
import os
import datetime
%matplotlib inline
Step 2:¶
Read the DataSet¶
In [6]:
df = pd.read_csv("AEP_hourly.csv")
df.head(3)
Out[6]:
In [7]:
df.info()
In [8]:
df.describe()
Out[8]:
Step 3:¶
seperate date and time¶
In [18]:
df["New_Date"] = pd.to_datetime(df["Datetime"]).dt.date
df["New_Time"] = pd.to_datetime(df["Datetime"]).dt.time
In [20]:
df1 = df
df1.head(2)
Out[20]:
Step 4:¶
When was the higest Energy Consumption and which Year¶
Maximum¶
In [21]:
df1[df1["AEP_MW"] == df["AEP_MW"].max()]
Out[21]:
Minimum¶
In [22]:
df1[df1["AEP_MW"] == df["AEP_MW"].min()]
Out[22]:
Conclusion : From Step 4 we can say that Maximum Energy was Consumed during 2016-10-02 at 05:00:00 and it was 9581.0 MW and Minimum was on 2008-10-20 at 14:00:00 and was 25695.0 MW¶
Step 5:¶
Plot and Data visualization¶
In [24]:
sns.distplot(df1["AEP_MW"])
Out[24]:
Step 7: Extract Date and Time¶
In [36]:
df1.head(2)
Out[36]:
In [38]:
df1["Year"] = pd.DatetimeIndex(df['New_Date']).year
In [39]:
df1.head(2)
Out[39]:
Check how many Years are Unique¶
In [41]:
df1["Year"].unique()
Out[41]:
This Tell us that there are 10 Unique Year from 2004 to 2018¶
In [43]:
df1[df1["Year"] == 2013].nunique()
Out[43]:
shows the Relationship of Energy vs Year¶
In [44]:
sns.lineplot(x=df1["Year"],y=df1["AEP_MW"], data=df1)
Out[44]:
Regression¶
In [48]:
sns.jointplot(x=df1["Year"],
y=df1["AEP_MW"],
data=df1,
kind="reg")
Out[48]:
In [49]:
sns.jointplot(x=df1["Year"],
y=df1["AEP_MW"],
data=df1,
kind="kde")
Out[49]:
Let us see the relation between Energy and Time¶
In [51]:
sns.lineplot(x=df1["New_Time"],y=df1["AEP_MW"], data=df1)
Out[51]:
No comments:
Post a Comment