I need to select the rows +- 1sec from specific lines (marked as to_pick)
I can do it with loops, but I looking for more elegant way
import pandas as pd
import numpy as np
N = 1000
tidx = pd.date_range('2019-07-01 09:30:00', periods=N, freq='S')
np.random.seed(3)
data = np.random.randn(N)
ts = tidx + pd.to_timedelta(pd.np.random.randn(N), unit='s')
df = pd.DataFrame({'Time': ts, 'to_pick': pd.np.random.randn(N) > 0.98, 'start': ts - pd.to_timedelta(1, 's'), 'end': ts + pd.to_timedelta(1, 's')})
df.loc[~df['to_pick'], 'start'] = pd.np.nan
df.loc[~df['to_pick'], 'end'] = pd.np.nan
I am looking for something like
df['Time'].between(df['start', df['end'])
that will work to combine the conditions