Is there a way to group time series on all the dates every 30 minutes or x minutes. My question is very similar to this one. If I wanted to group by hours in a date, I would just need
data=pd.DataFrame({'Values': 1,'Date':pd.date_range('01-01-2017',periods=3600,freq='T')})
data.set_index(['Date'],inplace=True)
grouped=data.groupby(data.index.hour)
Running a for-loop and printing the last group give me:
for time,group in grouped:
print(group)
Values
Date
2017-01-01 23:00:00 1
2017-01-01 23:01:00 1
2017-01-01 23:02:00 1
2017-01-01 23:03:00 1
2017-01-01 23:04:00 1
2017-01-01 23:05:00 1
2017-01-01 23:06:00 1
2017-01-01 23:07:00 1
2017-01-01 23:08:00 1
2017-01-01 23:09:00 1
2017-01-01 23:10:00 1
2017-01-01 23:11:00 1
2017-01-01 23:12:00 1
2017-01-01 23:13:00 1
2017-01-01 23:14:00 1
2017-01-01 23:15:00 1
2017-01-01 23:16:00 1
2017-01-01 23:17:00 1
2017-01-01 23:18:00 1
2017-01-01 23:19:00 1
2017-01-01 23:20:00 1
2017-01-01 23:21:00 1
2017-01-01 23:22:00 1
2017-01-01 23:23:00 1
2017-01-01 23:24:00 1
2017-01-01 23:25:00 1
2017-01-01 23:26:00 1
2017-01-01 23:27:00 1
2017-01-01 23:28:00 1
2017-01-01 23:29:00 1
...
2017-01-02 23:30:00 1
2017-01-02 23:31:00 1
2017-01-02 23:32:00 1
2017-01-02 23:33:00 1
2017-01-02 23:34:00 1
2017-01-02 23:35:00 1
2017-01-02 23:36:00 1
2017-01-02 23:37:00 1
2017-01-02 23:38:00 1
2017-01-02 23:39:00 1
2017-01-02 23:40:00 1
2017-01-02 23:41:00 1
2017-01-02 23:42:00 1
2017-01-02 23:43:00 1
2017-01-02 23:44:00 1
2017-01-02 23:45:00 1
2017-01-02 23:46:00 1
2017-01-02 23:47:00 1
2017-01-02 23:48:00 1
2017-01-02 23:49:00 1
2017-01-02 23:50:00 1
2017-01-02 23:51:00 1
2017-01-02 23:52:00 1
2017-01-02 23:53:00 1
2017-01-02 23:54:00 1
2017-01-02 23:55:00 1
2017-01-02 23:56:00 1
2017-01-02 23:57:00 1
2017-01-02 23:58:00 1
2017-01-02 23:59:00 1
But there is no times.30min
command.
EDIT:
I am trying to group every thirty minutes for all the dates. I want the output exactly like the above command but for an x minutes. The default grouped = df.groupby(pd.TimeGrouper('30T'))
does not work, because it groups the dates individually. So if I have minute timestamps of dates say 2017-01-01 and 2017-01-02, pd.TimeGrouper('30T')
, splits up 0:00-0:30 2017-01-01
and 0:00-0:30 2017-01-02
into seperate groups. I would like them combined.