Create numpy matrix filled with NaNs

后端 未结 8 1294
灰色年华
灰色年华 2020-12-04 07:40

I have the following code:

r = numpy.zeros(shape = (width, height, 9))

It creates a width x height x 9 matrix filled with zero

8条回答
  •  误落风尘
    2020-12-04 08:26

    Another option is to use numpy.full, an option available in NumPy 1.8+

    a = np.full([height, width, 9], np.nan)
    

    This is pretty flexible and you can fill it with any other number that you want.

提交回复
热议问题