I found a similar ans in php get time intervals with time range
I would like to filter my data frame every certain interval. Is there a simple way to do that? For example, from 1100-1200, I would like to get a subset of the df of every three mins.
This is my code
# the time column is as follows
df['time']= pd.to_datetime(df['time'])
df['time'] = df['time'].dt.tz_localize('UTC').dt.tz_convert('Asia/Hong_Kong')
df['time'] = df['time'].dt.time
start = datetime.strptime('11:00:00', '%H:%M:%S').time()
end = datetime.strptime('11:03:00', '%H:%M:%S').time()
df= df[df['time'].between(start, end)]
doSth(df)
I would like to change it to sth like:
for i in range(1100:1200)
start = datetime.strptime(i, '%H:%M:%S').time()
end = datetime.strptime(i+3, '%H:%M:%S').time()
df= df[df['time'].between(start, end)]
doSth(df)