I want to create a numpy array in which each element must be a list, so later I can append new elements to each.
I have looked on google and here on stack overflow a
Just found this, I've never answered a question before, but here is a pretty simple solution:
If you want a vector of length n, use:
A = np.array([[]]*n + [[1]])[:-1]
This returns:
array([list([]), list([]), ... , list([])], dtype=object)
If instead you want an n by m array, use:
A = np.array([[]]*n*m + [[1]])[:-1]
B = A.reshape((n,m))
For higher rank arrays, you can use a similar method by creating a long vector and reshaping it. This may not be the most efficient way, but it worked for me.