import numpy as np X = np.array( [[ 0.4, 1.2, -0.6], [ 1.6, -0.9, 0.5], [-0.4, -1.4, 1.7]] ) Z = np.where(X < 0, 0, X) print(Z)