9951 explained code solutions for 126 technologies

python-numpyHow to use where() to filter array

import numpy as np

array = np.arange(0, 100).reshape(10,10)

filtered = array[np.where(array > 80)]ctrl + c
import numpy as np

load Numpy module for Python


generates array based on specified range


changes shape of the array to the specified dimensions


returns filtered elements from array based on condition

array > 80

sample condition (choose only elements which value is more than 80)