One solution would be:
import numpy as np
a = np.array([1, 2, 3, 4, 5])
(a > 1) & (a < 5) # 1 < element < 5?
# array([False, True, True, True, False])
More Related Contents:
- Convert a 3D array to RGB valued array [closed]
- Why does multiprocessing use only a single core after I import numpy?
- Replacing Numpy elements if condition is met
- Matplotlib log scale tick label number formatting
- What does the term “broadcasting” mean in Pandas documentation?
- Save / load scipy sparse csr_matrix in portable data format
- Working with TIFFs (import, export) in Python using numpy
- Most efficient way to sort an array into bins specified by an index array?
- Shift elements in a numpy array
- Numpy and line intersections
- Render NumPy array in FastAPI
- Numpy: Creating a complex array from 2 real ones?
- Are Decimal ‘dtypes’ available in NumPy?
- Fill zero values of 1d numpy array with last non-zero values
- Error “Import Error: No module named numpy” on Windows
- Binary numpy array to list of integers?
- Weighted percentile using numpy
- test for membership in a 2d numpy array
- Replace sub part of matrix by another small matrix in numpy
- pandas.read_csv from string or package data
- python tilde unary operator as negation numpy bool array
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- One Hot Encoding using numpy [duplicate]
- Is there a numpy/scipy dot product, calculating only the diagonal entries of the result?
- numpy – evaluate function on a grid of points
- How can I draw lines into numpy arrays?
- How can I turn a flat list into a 2D array in python?
- Get the indices of N highest values in an ndarray
- How to convert a 3d numpy array to 2d
- Numpy.dtype has the wrong size, try recompiling