This function uses boolean indexing to create a mask based on the conditions provided and then applies the mask to the input array to filter out the values not in between the specified thresholds.
import numpy as np
def not_in_between(array, lower, upper):
# Create a boolean mask for values not in between lower and upper thresholds
mask = (array <= lower) | (array >= upper)
# Use the boolean mask to filter the values
result = np.array(array)[mask]
return result
# Example usage:
input_array = np.array([1, 2, 3, 4])
lower_threshold = 1
upper_threshold = 3
result_array = not_in_between(input_array, lower_threshold, upper_threshold)
print(result_array)