II. Visualisation¶
A. Total Consumption¶
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(12, 5))
ax.plot(df['Total Energy Consumption (kWh)'], label='Total Energy Consumption', color='blue')
ax.set_title('Total Energy Consumption')
ax.set_xlabel('Date')
ax.set_ylabel('Energy Consumption (kWh)')
ax.legend()
ax.grid(True)
plt.tight_layout()
plt.show()
B. Total Consumption by year¶
# Chart: Total Energy Consumption by Year (Aggregated with different bar colors)
import matplotlib.pyplot as plt
yearly_consumption = df['Total Energy Consumption (kWh)'].resample('Y').sum()
colors = ['red', 'green', 'blue', 'orange', 'purple', 'cyan']
fig, ax = plt.subplots(figsize=(10, 5))
ax.bar(yearly_consumption.index.year, yearly_consumption.values, color=colors[:len(yearly_consumption)])
ax.set_title('Total Energy Consumption by Year')
ax.set_xlabel('Year')
ax.set_ylabel('Total Energy Consumption (kWh)')
ax.grid(axis='y', linestyle='--', alpha=0.7)
plt.tight_layout()
plt.show()
C. Total Consumption by month¶
import pandas as pd
import matplotlib.pyplot as plt
monthly_consumption = df['Total Energy Consumption (kWh)'].resample('M').sum()
monthly_df = monthly_consumption.to_frame()
monthly_df['Year'] = monthly_df.index.year
monthly_df['Month'] = monthly_df.index.month_name()
pivot = monthly_df.pivot_table(
index='Month',
columns='Year',
values='Total Energy Consumption (kWh)',
aggfunc='sum'
)
month_order = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December'
]
pivot = pivot.reindex(month_order)
# Plot grouped bar chart
pivot.plot(kind='bar', figsize=(14, 6), color=plt.cm.tab10.colors[:len(pivot.columns)])
plt.title('Total Energy Consumption by Month (Grouped by Year)')
plt.xlabel('Month')
plt.ylabel('Total Energy Consumption (kWh)')
plt.legend(title='Year')
plt.grid(axis='y', linestyle='--', alpha=0.7)
plt.tight_layout()
plt.show()
D. Grid Feed-In¶
The total of the vertical in feed into the Swiss Transmission grid is the sum of all time series of production metering points and other in feeds over transformers and lines into the transmission grid.
fig, ax = plt.subplots(figsize=(12, 5))
df = df.resample('7D').sum()
ax.plot(df['Grid Feed-In (kWh)'], label='Total Energy Consumption', color='red')
ax.set_title('Grid Feed-In (kWh)')
ax.set_xlabel('Date')
ax.set_ylabel('Grid Feed-In (kWh)')
ax.legend()
ax.grid(True)
plt.tight_layout()
plt.show()
E. Secondary Control Energy Prices (€/MWh)¶
These prices represent the cost per megawatt-hour (MWh) for activating secondary control (also called automatic frequency restoration reserve, aFRR) in the Swiss power grid. Secondary control energy is used to balance short-term fluctuations between electricity supply and demand, maintaining grid frequency close to its nominal value (e.g., 50 Hz). The price reflects the market cost for procuring this balancing service from providers, and is typically determined through auctions or market mechanisms operated by Swissgrid.
fig, ax = plt.subplots(figsize=(12, 5))
ax.plot(df['Secondary Control Energy Prices (€/MWh)'], label='Secondary Control Energy Prices (€/MWh)', color='orange')
ax.set_title('Secondary Control Energy Prices (€/MWh)')
ax.set_xlabel('Date')
ax.set_ylabel('Secondary Control Energy Prices (€/MWh)')
ax.legend()
ax.grid(True)
plt.tight_layout()
plt.show()
F. Visualising Weather¶
# Ensure proper formatting
assert isinstance(weekly_temp, pd.Series)
weekly_temp = weekly_temp.dropna()
weekly_temp.index = pd.to_datetime(weekly_temp.index)
# Aggregate to monthly mean temperature
monthly_temp = weekly_temp.resample("M").mean()
# Plot as line chart
plt.figure(figsize=(12, 5))
plt.plot(monthly_temp.index, monthly_temp.values, marker='o', linestyle='-', linewidth=1.5)
plt.title("Monthly Avg Temperature over Switzerland (Kelvin)")
plt.xlabel("Month")
plt.ylabel("Monthly Mean Temp (K)")
plt.grid(True, linestyle='--', alpha=0.5)
plt.tight_layout()
plt.show()