9951 explained code solutions for 126 technologies


python-numpyHow to filter Numpy array


import numpy as np

array = np.array([1,2,3,4,5])
filtered = array[array >= 3]ctrl + c
import numpy as np

load Numpy module for Python

np.array

declare Numpy array

array >= 3

condition to filter upon (selects all array values bigger or equal to 3)

array[array >= 3]

filteres array based on condition expression

filtered

will contain filtered array