I can start with a 2 element object dtype array:
In [351]: M = np.array((None,None))
In [352]: M.shape
Out[352]: (2,)
In [353]: M
Out[353]: array([None, None], dtype=object)
In [354]: M[0]=(5,)
In [355]: M[1]=()
In [356]: M
Out[356]: array([(5,), ()], dtype=object)
In [357]: print(M)
[(5,) ()]
Or more directly (from a list of tuples) (beware, sometimes this produces a error rather than object array).
In [362]: np.array([(55,),()])
Out[362]: array([(55,), ()], dtype=object)
But I don't see what it's good for. It would easier to construct a list of tuples:
In [359]: [(5,), ()]
Out[359]: [(5,), ()]
Do not try to use np.append like the list append. It is just a clumsy front end to np.concatenate.
M as you create it is:
In [360]: M = np.array(((),()))
In [361]: M
Out[361]: array([], shape=(2, 0), dtype=float64)
It can't hold any elements. And you can't change the shape of the slots as you can with a list. In numpy shape and dtype are significant.
You can specify object dtype:
In [367]: M = np.array([(),()], object)
In [368]: M
Out[368]: array([], shape=(2, 0), dtype=object)
but it's still impossible to reference and change one of those 0 elements.
ndarray? Whatshapeanddtypeare you aiming for? What kinds of calculations are you going to do with this array?ndarrayis fixed. You can reshape it, but the total number of elements has to remain unchanged. To add elements you have to make a new array, and copy values. If you do need to create an array incrementally, it's best to create lists (or lists of lists) and do one type conversion, or preallocate the array, and fill in values incrementally.