I want to create an array with dtype=np.object
, where each element is an array with a numerical type, e.g int or float. For example:
>>>
I think anyarray is what you need here:
b = np.asanyarray([a,a,a])
>>> b[0].dtype
dtype('int32')
not sure what happened to the other 32bits of the ints though.
Not sure if it helps but if you add another array of a different shape, it converts back to the types you want:
import numpy as np
a = np.array([1,2,3])
b = np.array([1,2,3,4])
b = np.asarray([a,b,a], dtype=np.object)
print(b.dtype)
>>> object
print(b[0].dtype)
>>> int32