Skip to content

Instantly share code, notes, and snippets.

@SungYK
Created July 31, 2020 03:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SungYK/4a23c94c9eb6b275d3d2bd90a0b2a5dd to your computer and use it in GitHub Desktop.
Save SungYK/4a23c94c9eb6b275d3d2bd90a0b2a5dd to your computer and use it in GitHub Desktop.
>>> arr = np.array([0,1,2,3,4,5,6,7,8,9])
>>> arr
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> mask = np.array([1,3,5,7])
>>> arr[mask]
array([1, 3, 5, 7])
>>> do some operation
array([0, 1, 0, 3, 0, 5, 0, 7, 0, 0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment