我有一个空的numpy数组,还有另一个填充了值的数组。我想将空的numpy数组用填充后的数组填充x次。
当x = 3时,最初的空数组看起来像
我尝试过这个:
但是要注意,以下内容非常重要。
当x = 3时,最初的空数组看起来像
[[populated_array],[populated_array], [populated_array]]
其中populated_array每次都是相同的值/数组。我尝试过这个:
a = np.empty(3)
a.fill(np.array([4,6,6,1]))
但是要注意,以下内容非常重要。
ValueError: Input object to FillWithScalar is not a scalar
and want this
[[4,6,6,1],[4,6,6,1],[4,6,6,1]]
感谢任何帮助。
a = np.empty(3,dtype=object)
。 - Divakar