Skip to content

Instantly share code, notes, and snippets.

@SZanlongo
Created March 8, 2019 17:19
Show Gist options
  • Save SZanlongo/29ad221661e2b1fc163a79b2f90e90af to your computer and use it in GitHub Desktop.
Save SZanlongo/29ad221661e2b1fc163a79b2f90e90af to your computer and use it in GitHub Desktop.
Replace negative values in numpy array with zero
import numpy as np
a = np.array([[0, 19], [-1, 8], [-2, -20]])
a = a.clip(0)
print(a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment