Skip to content

Instantly share code, notes, and snippets.

@photizzo
Last active January 5, 2018 23:48
Show Gist options
  • Save photizzo/3090beab4cf1ecdfd133b28c5f85f012 to your computer and use it in GitHub Desktop.
Save photizzo/3090beab4cf1ecdfd133b28c5f85f012 to your computer and use it in GitHub Desktop.
import numpy as np
array = [[True, False], [True, True]] # (2,2) array of boolean values
array_cond_true = [[1, 2], [3, 4]] # (2,2) array of where to pick values if array at position is true
array_cond_false = [[9, 8], [7, 6]] # (2,2) array of where to pick values if array at position is false
print ("result: \n" + str(np.where(array,
array_cond_true,
array_cond_false)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment