Replace values of a numpy index array with values of a list

后端 未结 6 826
迷失自我
迷失自我 2020-12-15 04:31

Suppose you have a numpy array and a list:

>>> a = np.array([1,2,2,1]).reshape(2,2)
>>> a
array([[1, 2],
       [2, 1]])
>>> b = [         


        
6条回答
  •  爱一瞬间的悲伤
    2020-12-15 05:19

    I was unable to set the flags, or use a mask to modify the value. In the end I just made a copy of the array.

    a2 = np.copy(a)
    

提交回复
热议问题