Home > front end >  plotting graph of day from a years data
plotting graph of day from a years data

Time:08-01

So I have a dataset that has electricity load over 24 hours:

Time_of_Day = loadData.groupby(loadData.index.hour).mean()

Time_of_Day

        Time       Load    
2019-01-01 01:00:00 38.045
2019-01-01 02:00:00 30.675
2019-01-01 03:00:00 22.570
2019-01-01 04:00:00 22.153
2019-01-01 05:00:00 21.085
... ...
2019-12-31 20:00:00 65.565
2019-12-31 21:00:00 53.513
2019-12-31 22:00:00 49.096
2019-12-31 23:00:00 44.409
2020-01-01 00:00:00 45.744

how do I plot a random day(24hrs) from the 8760 hours please

CodePudding user response:

With the following toy dataframe:

import pandas as pd
import random

df = pd.DataFrame({"Time": pd.date_range(start="1/1/2019", end="12/31/2019", freq="H")})
df["Load"] = [round(random.random() * 100, 2) for _ in range(df.shape[0])]
                    Time   Load
0    2019-01-01 00:00:00  53.36
1    2019-01-01 01:00:00  34.20
2    2019-01-01 02:00:00  64.19
3    2019-01-01 03:00:00  89.18
4    2019-01-01 04:00:00  27.82
...                  ...    ...
8732 2019-12-30 20:00:00  38.26
8733 2019-12-30 21:00:00  49.66
8734 2019-12-30 22:00:00  64.15
8735 2019-12-30 23:00:00  23.97
8736 2019-12-31 00:00:00   3.72

[8737 rows x 2 columns]

Here is one way to do it using enter image description here

  • Related