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
  Using machine learning kingrayd 1 258 Apr-09-2019, 09:29 AM
Last Post: micseydel
  Pandas Indexing with duplicates energerecontractuel 3 278 Mar-07-2019, 12:57 AM
Last Post: scidam
  Python - Database for Machine Learning application braveYug 2 429 Mar-04-2019, 10:30 AM
Last Post: Shruti7109162
  About Machine Learning rajeev1729 3 1,397 Mar-01-2019, 07:41 AM
Last Post: rajeev1729
  future warning when using numpy fancy indexing bluefrog 0 660 Nov-20-2018, 09:44 AM
Last Post: bluefrog
  General Coding help:Reinforcement learning kala 1 452 Oct-13-2018, 05:49 PM
Last Post: ichabod801
  Pick a line in a plot with matplotlib Romain 2 604 Sep-18-2018, 01:41 PM
Last Post: Romain
  3D Object Recognition using Deep Learning chandininair 0 509 Aug-08-2018, 11:29 PM
Last Post: chandininair
  Learning Python alpbetaC0der 5 1,867 Aug-05-2018, 05:20 PM
Last Post: ahsankhan
  Convert indexing For Loop from MATLAB (uses numpy and pandas) bentaz 3 869 Mar-20-2018, 08:29 PM
Last Post: bentaz

Forum Jump:


Users browsing this thread: 1 Guest(s)