I got a pretty straightforward problem and there must be a simple way to solve such problem. Consider the following dataframe:
import pandas as pd
df = pd.DataFrame()
start = pd.Timestamp('2013-08-14T00:00')
end = pd.Timestamp('2013-08-15T00:00')
t = np.linspace(start.value, end.value, 60*60*24+1)
df['Timestamp'] = pd.to_datetime(t)
Now I want to create one column df['Action'] which is a boolean, signalling true for intervals of 5s. So as outcome, I expect something like this:
Timestamp Action
0 2013-08-14 00:00:00 False
1 2013-08-14 00:00:01 False
2 2013-08-14 00:00:02 False
3 2013-08-14 00:00:03 False
4 2013-08-14 00:00:04 False
5 2013-08-14 00:00:05 True
6 2013-08-14 00:00:06 False
7 2013-08-14 00:00:07 False
8 2013-08-14 00:00:08 False
9 2013-08-14 00:00:09 False
10 2013-08-14 00:00:10 True
11 2013-08-14 00:00:11 False
Yes, I could play with the index however that doesn't seem really elegant. I also want to be able to adjust the interval for different inputs.
Hope that I managed to be succinct and precise. I would really appreciate your help on this one!