I have a two values that are being found in a for loop like so:
for i in range(df_zones.shape[0]):
filter_max = df_labels[df_labels['Labels'] == i].sort_values(by='level').iloc[-1]
filter_min = df_labels[df_labels['Labels'] == i].sort_values(by='level').iloc[0]
I have another dataframe with 4 columns of measurements with a timeseries index, like so:
DateTime
meas1
meas2
meas3
meas4
2022-1-1
1.1
1.2
1.3
1.1
There are 1000's of rows of data.
What I am trying to do is have another column that is labeled as 'isZone', where this means, are any of the values in the row between filter_max and filter_min.
DateTime
meas1
meas2
meas3
meas4
isZone
2022-1-1
1.1
1.5
1.5
1.7
0
2022-1-2
2.2
1.4
1.5
1.7
0
2022-1-3
3.1
1.2
1.3
1.1
1
2022-1-4
4.1
1.2
1.3
1.1
1
2022-1-5
5.1
1.2
1.3
1.1
1
I have read about the pandas between function. But I really can't figure out how to make this work. Is there a quicker way to do this in numpy? any guidance would be appreciated.