Home > Blockchain >  plotting a graph for 24 hours from a year data
plotting a graph for 24 hours from a year data

Time:07-21

I have a dataset of 100 households' electricity consumption over 8760 hours. I have managed to plot the load over the year quite easily. However, I'm struggling to plot a graph showing changes over the 24 hours in a day.

householdData = pd.read_excel('/content/drive/MyDrive/Diss/cleanedInputData/100households.xls')
householdData
print(householdData)
  Time  Affluent  Adversity  Affluent  Comfortable  \
0    2019-01-01 01:00:00     0.254      0.244     0.155        0.215   
1    2019-01-01 02:00:00     0.346      0.154     0.083        0.246
2    2019-01-01 03:00:00     0.309      0.116     0.085        0.220   
3    2019-01-01 04:00:00     0.302      0.158     0.083        0.226   
4    2019-01-01 05:00:00     0.181      0.171     0.096        0.246   
...                  ...       ...        ...       ...          ...   
8755 2019-12-31 20:00:00     1.102      0.263     2.157        0.209   
8756 2019-12-31 21:00:00     0.712      0.269     1.409        0.212   
8757 2019-12-31 22:00:00     0.398      0.274     0.073        0.277   
8758 2019-12-31 23:00:00     0.449      0.452     0.072        0.252   
8759 2020-01-01 00:00:00     0.466      0.291     0.110        0.203 

I then set time as index by:

Energy= householdData.set_index('Time')  

from this im able to resample to days like:

Daily_kWh= Energy.resample("D").sum()
Daily_kWh

I tried plotting the graph using

#load v time of year
fig, ax = plt.subplots(figsize = (16,5))
ax.plot(Energy,  label='Hourly consumption',color = 'blue')
ax.set_ylabel('Hourly consumption [kWh]',size=15, color='green')
ax.set_xlabel('Time',size=15)

however this gives me a graph over the year. If i was to try find a graph over 24 hours for the households, how would i please do that. I've also tried aggregating all the loads into one hourly load but just can't seem to plot an hour graph.

Many thanks

Screenshots of codes.

plot of temperature vs hour of day

  • Related