I have a pandas dataframe as the following
data
Out[8]:
value1
Date
2015-03-31 09:53:53.800 NaN
2015-03-31 10:28:54.700 1.34
2015-03-31 10:34:35.720 NaN
2015-03-31 10:36:53.540 1.26
2015-04-01 11:37:11.620 1.44
2015-04-01 11:39:30.520 NaN
2015-04-01 11:50:25.620 1.76
2015-04-02 11:50:30.620 1.38
2015-04-02 12:31:20.220 1.76
2015-04-02 12:37:43.940 2.36
2015-04-03 12:38:45.820 1.46
2015-04-03 12:41:56.680 2.26
2015-04-04 13:04:50.740 1.16
2015-04-05 12:38:45.820 1.46
2015-04-05 12:41:56.680 2.26
2015-04-05 13:04:50.740 1.16
and I would like to compute the mean of the values belonging to the days 0-2-4 and the mean of the values belonging to the days 1-3-5 How can I use groupby on the dates to do so?
df2 = data.groupby(?).agg(np.mean)
Try this:
Explanation: