Skip to content

Instantly share code, notes, and snippets.

@towry
Created June 15, 2019 09:58
Show Gist options
  • Save towry/ce7d541fc3b542cb04c73c4ee65dfb93 to your computer and use it in GitHub Desktop.
Save towry/ce7d541fc3b542cb04c73c4ee65dfb93 to your computer and use it in GitHub Desktop.
pythonic
a = np.array([[1,2,3],
[3,2,4]])
my_dict = {1:23, 2:34, 3:36, 4:45}
np.vectorize(my_dict.get)(a)
```
array([[23, 34, 36],
[36, 34, 45]])
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment