So I have a df like this:
import pandas as pd
import numpy as np
datatime = [('2019-09-15 00:15:00.000000000'),
('2019-09-15 00:30:00.000000000'),
('2019-09-15 00:45:00.000000000'),
('2019-09-15 01:00:00.000000000'),
('2019-09-15 01:15:00.000000000'),
('2019-09-15 01:30:00.000000000'),
('2019-09-15 01:45:00.000000000'),
('2019-09-15 02:00:00.000000000'),
('2019-09-15 02:15:00.000000000')]
p =[494.76,486.36,484.68,500.64,482.16,483.84,483.0,478.8,493.08,474.6]
q = [47.88,33.6,41.16,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
df = pd.DataFrame(list(zip(datatime,p,q)), columns = [['datetime','p','q']])
df
I am doing an analysis for 30 days by grouping my data into on-peak and off-peak hours. For this I also need to identify the days of the week. I tried use the pandas function:
df.dt.day_name()
But in this particular case it is not feasible since for this function the day start at 00:00:00 and at my program I need it to start at 00:15:00.
Since I have 96 points for each day, I thought about using a dictionary:
days_of_the_week = {'Sunday': 1,'Monday': 2,'Tuesday': 3, 'Wednesday': 4, 'Thursday':5, 'Friday':6 , 'Saturday':7}
How can I apply it to my df so that every 96 points a new day is identified?