在下面。 numpy数组,我想替换匹配-1.0与0.0
的任何值array([[ 89.75, 90. ],
[ 89.5 , 89.75],
[ 89.25, 89.5 ],
...,
[-89.5 , -89.25],
[-89.75, -89.5 ],
[-90. , -89.75]], dtype=float32)
然而,这会产生错误:
var[var == mask_val] = default_val # mask_val is -1.0 and default_val is 0.0
*** IndexError: Index cannot be multidimensional