Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Learning indexing with python, pick dates
#1
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
Quote
#2
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,
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Pandas Indexing with duplicates energerecontractuel 3 393 Mar-07-2019, 12:57 AM
Last Post: scidam
  Pick a line in a plot with matplotlib Romain 2 806 Sep-18-2018, 01:41 PM
Last Post: Romain
  python array/cell/indexing python 1 838 Feb-08-2018, 11:18 AM
Last Post: DeaD_EyE
  Extract data between two dates from a .csv file using Python 2.7 sujai_banerji 1 4,436 Nov-15-2017, 09:48 PM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)