How can be used multiple filter in the numpy array?
arrays, numpy, python
Solution
You can intersect two filters with the `&` operator:
data = data[(data['RotSpeed'] <= ROTOR_SPEED) & (data['HorWindV'] <= WIND_SPEED)]
Or union two conditions with the `|` operator:
data = data[(data['RotSpeed'] <= ROTOR_SPEED) | (data['HorWindV'] <= WIND_SPEED)]
make sure to use parentheses around the field and the filter placed for it
It is unlikely to be much of an optimization though.
Problem
I am trying to filter some data out from an array ``` data = data[data['RotSpeed'] <= ROTOR_SPEED ] data = data[data['HorWindV'] <= WIND_SPEED ] ``` I am wondering if this can be optimized by combining the two filter?