Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9085757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:19:17+00:00 2026-06-16T21:19:17+00:00

I have a DataFrame with the following structure: <class ‘pandas.core.frame.DataFrame’> DatetimeIndex: 3333 entries, 2000-01-03

  • 0

I have a DataFrame with the following structure:

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 3333 entries, 2000-01-03 00:00:00+00:00 to 2012-11-21 00:00:00+00:00
Data columns:
open          3333  non-null values
high          3333  non-null values
low           3333  non-null values
close         3333  non-null values
volume        3333  non-null values
amount        3333  non-null values
pct_change    3332  non-null values
dtypes: float64(7)

The pct_change column contains percent change data.

Given a filtered DatetimeIndex from the DataFrame above:

<class 'pandas.tseries.index.DatetimeIndex'>
[2000-03-01 00:00:00, ..., 2012-11-01 00:00:00]
Length: 195, Freq: None, Timezone: UTC

I want to filter starting each date entry and return the first row where pct_change column is below 0.015.

I came up with this solution but it is very slow:

stops = []
#dates = DatetimeIndex
for d in dates:
    #check if pct_change is below -0.015 starting from date of signal. return date of first match
    match = df[df["pct_change"] < -0.015].ix[d:][:1].index

    stops.append([df.ix[d]["close"], df.ix[match]["close"].values[0]])

Any suggestions on how I can improve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:19:19+00:00Added an answer on June 16, 2026 at 9:19 pm

    How about this:

    result = df[df.pct_change < -0.015].reindex(filtered_dates, method='bfill')

    The only problem with this is that if an interval does NOT contain a value below -0.015, it will retrieve one from a future interval. If you add a column containing the date you can see the time each row came from, then set rows to NA if the retrieved timestamp exceeds the next “bin edge”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a a dataframe with the following structure: <class 'pandas.core.frame.DataFrame'> Int64Index: 1152 entries,
I have a Multindex DataFrame with the following structure: 0 1 2 ref A
I have the following dataframe: sp <- combn(c(sp1,sp2,sp3,sp4),2) d <- data.frame(t(sp),freq=sample(0:100,6)) and two factors
I have the following dataframe: DF <- data.frame(x = c(1, 2, 3,NA), y =
I have the following pandas Dataframe: from pandas import DataFrame, MultiIndex index = MultiIndex.from_tuples(zip([21,22,23],[45,45,46]),
I have a data frame with something like the following structure: Trial Index Condition1
Suppose I have the following DataFrame (timeseries, first column is a DateTimeIndex) atn file
Say I have the following R data.frame ZZZ : ( ZZZ <- structure(list(n =
Suppose you have a data frame with the following structure: df <- data.frame(a=c(1,2,3,4), b=c(job1;job2,
I have the following data frame: id,property1,property2,property3 1,1,0,0 2,1,1,0 3,0,0,1 4,1,1,1 d.f <- structure(list(id

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.