📜  带有字典的 numpy 数组映射值 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:32.230000             🧑  作者: Mango

代码示例1
>>> 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]])