0

I want to create a mask on pandas that obeys a time series index.

Suppose I have a pandas series ranging from values 0 to 100. I want to mark the series at a specific set of indices TRUE if it lies between 40 and 80, but in respects to time.

For example, if at t=0, the value of the series is 85, and t=1, the value is 50, I do not want to mark t=1 as true. I would only want to mark it as true if for some time step before T=t, the value is 40 or below and did not go above time step 80.

Rhubarb
  • 198
  • 1
  • 11
  • Hi there, could you please post a sample `DataFrame` to show your data (or a shortened version of your data)? – edesz Apr 20 '19 at 01:12

1 Answers1

1

Seems like you are looking for:

markers = df.value.le(80) & df.value.shift().le(40)
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74