Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

numpy aray map values with dictionary

>>> 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]])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #numpy #aray #map #values #dictionary
ADD COMMENT
Topic
Name
1+2 =