Learning indexing with python, pick dates - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Learning indexing with python, pick dates (/thread-19703.html) |
Learning indexing with python, pick dates - dervast - Jul-11-2019 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]
end=small_df.index[10] 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 RE: Learning indexing with python, pick dates - scidam - Jul-11-2019 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, |