Python Forum

Full Version: Learning indexing with python, pick dates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,
I have two data frames both contain time indexes with the same time period.
I want to pick start and end periods from the first data frame

start=small_df.index[1]
Output:
Out[894]: Timestamp('2019-02-08 07:53:33.360000')
end=small_df.index[10]
Output:
Out[895]: Timestamp('2019-02-08 07:54:00.149000')
and then I want to pick the numeric indexes from a second data frame where these time stamps fall in.



Can you think of an elegant way to do that?
Thanks a lot
Alex
I think, quite elegant would be a two stage approach, e.g.
cond = (df2.index > start) & (df2.index < end)
df2.reset_index()[cond].index     # or concat `.tolist()` statement,