Q:

pandas average by timestamp and day of the week

I have a pandas data frame with the following format:
            ds                    sensor_id           measurement
0    2019-09-13 12:40:00             20053             0.916667           
1    2019-09-13 12:45:00             20053             0.583333           
2    2019-09-13 12:50:00             20053             0.733333   

....

2837 2019-09-23 17:20:00             20053             2.900000

What I want to do is generate a new data frame where the measurements are averaged for these 5 minute time blocks based on the day of the week. i.e. averaged over 5 minutes for every sunday, monday, tuesday and so on in the dataset and get this averaged dataframe for the whole week.
I know there are many functions to get the day  of week in pandas but I could not figure out how to use them to do this averaging.

A:

IIUC, something like this:
df = pd.DataFrame(np.random.random(2838),index=pd.date_range('2019-09-13 12:40:00', periods=2838, freq='5T'))

df.groupby(df.index.strftime('%A %H:%M')).mean()

Output:
                     0
Friday 00:00  0.992586
Friday 00:05  0.454352
Friday 00:10  0.747474
Friday 00:15  0.161208
Friday 00:20  0.422006
Friday 00:25  0.643614
Friday 00:30  0.450312
Friday 00:35  0.029722
Friday 00:40  0.316843
Friday 00:45  0.676068
...
Wednesday 23:10  0.424629
Wednesday 23:15  0.231609
Wednesday 23:20  0.987456
Wednesday 23:25  0.123619
Wednesday 23:30  0.203492
Wednesday 23:35  0.377411
Wednesday 23:40  0.131120
Wednesday 23:45  0.935324
Wednesday 23:50  0.910381
Wednesday 23:55  0.438193

