Based on this question: https://stackoverflow.com/a/8489498/9934156 I wanted to expand an existing numpy array and fill it with a variable amount of random columns.
My approach for this is:
target = 'data'
amount = 4
data = {'data': array([[1, 2],
[5, 9],
[4, 4],
[8, 42],
...,
N = data[target].shape
biggerarr = np.random.rand(N[0], N[1]+amount)
existingArr = np.array(data[target])
biggerarr[:,:] = existingArr
data[target] = a
But no matter how I play arround with it, I always get either
ValueError: could not broadcast input array from shape (200,2) into shape (200,6)
Or when I do existingArr[:,:] = biggerarr
ValueError: could not broadcast input array from shape (200,6) into shape (200,2)