MODULE6

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

MODULE-6

MEASURE ENERGY CONSUMPTION


MODAL DEVELOPENT&EVALUATION
Source code:
#import
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
df = pd.read_csv(“/input/hourly-electricity-consumption-and-
production/electricityConsumptionAndProductioction.csv”)
df = df.set_index(“DateTime”)
df.index = pd.to_datetime(df.index)
pd.set_option(‘display.max_columns’, None)
pd.set_option(‘expand_frame_repr’, False)
df.head()
print(df.shape)
#plot the data
df[["Consumption", "Production"]].plot(style="-", fig size=(15, 5),
title="Electricity Consumption and Production, in MW")
plt.ylabel('MW')
plt.show()
# add a new column for the delta
df["delta"] = df["Production"] - df["Consumption"]
plt.rcParams["figure.figsize"] = (15,5)
plt.bar(
df.index, df['delta'],
color=np.where(df['delta'] > 0, 'deepskyblue', 'crimson')
)
plt.title("Exports and imports of electricity, in MW")
plt.ylabel('MW')
plt.show()
# drop the column we have used for the delta
df.drop(["delta"], axis=1, inplace=True)
#weekly electricuty
df["2023-01-09 00:00:00" : "2023-01-15 23:59:59"]["Consumption"].plot(style="-
", figsize=(15, 5), title="Electricity Consumption and Production, in MW")
plt.show()
dfYear = df["2022-01-01 00:00:00" : "2022-12-31 23:59:59"]
productionTypes = ['Nuclear', 'Wind', 'Hydroelectric', 'Oil and Gas', 'Coal', 'Solar',
'Biomass']
colorMap = {"Nuclear":"r", "Wind":"c", "Hydroelectric":"b", "Oil and Gas":"k",
"Coal":"k", "Solar", "Biomass"}
for production Type in productionTypes:
dfYear[[production Type]].plot(style="-", figsize=(15, 5),
title=f"{productionType} Electricity Production, in MW",
color=colorMap.get(productionType))
plt.ylabel('MW')
plt.show()
#renewwables inspection
summer = df[["Hydroelectric", "Wind", "Solar"]]["2022-06-01 00:00:00" : "2022-
08-31 23:59:59"]
dfSummer.plot(style="-", figsize=(15, 6), title=f"Renewable Electricity
Production, in MW")
plt.ylabel('MW')
plt.show()

OUTPUT:

You might also like