I currently have a column in a dataframe, df[Stress]. I want to return the location of the rows in the column where the value stored is less than a variable, load_drop, but only within a certain range of the column, stated by first and last. I figured I could use np.where to find the locations, but so far I'm returning an empty array when I run the code. Here is what I have so far:
df = {'Stress': [1,2,3,6,7,8,10,12,14,20,19,17,15,13,12,10,8,7,6,4,1,0]
first = 10
last = 18
drop = 11
life_array = np.where(df['Stress'].iloc[first:last] < drop)
print (life_array)
[]
Ideally, my desired output would be this:
print(life_array)
0 15
1 16
2 17
3 18
Which is the the location of the rows where the condition is met. Can I use np.where and iloc in such a fashion?