I used numpy C api in C++ and got the following array in python:
>>> my_array
array([array([20211101., 20211101., 20211101., 20211101., 20211101.]),
array([10601155, 10603088, 10603982, 10600983, 10603283], dtype=int32),
array([30000011, 30000021, 30000031, 30000041, 30000051], dtype=int32),
array([93003000., 93003000., 93003000., 93003000., 93003000.]),
array([-1., -1., -1., 1., -1.]),
array([b'Sell', b'Sell', b'Sell', b'Buy', b'Sell'], dtype='|S4'),
array([b'SQZ', b'SQZ', b'SQZ', b'SQZ', b'SQZ'], dtype='|S4'),
array([ 100, 1100, 100, 200, 200], dtype=int32),
array([34.19, 9.97, 29.46, 8.96, 27.85]),
array([b'5', b'0', b'5', b'0', b'0'], dtype='|S4')], dtype=object)
The shape of this array is
>>> my_array.shape
(10,)
My purpose is to switch this array to a 2D numpy array and create a dataframe by pd.DataFrame(data=my_array). But I failed to do it because I am supposed to input some numpy array like
np.array([[...],[...],[...],...])
not
array([array([...]),array([...]),array([...]),...])
I understand that I can use a for loop to get the dataframe, but the speed would be very slow if the dataset is large. So is there any method to convert my array to a real 2D numpy array and get a dataframe object?
df = pd.DataFrame(a.T)asumingathe array?df = pd.DataFrame(my_array.T)anddf = pd.DataFrame(my_array)give me the same (1, 10) result. Is this because each element of my array is also an array?