I would like to convert each individual array in the nested arrays as each rows in the dataframes. For example: The nested arrays example is below. How do I create each numbers inside [[... ]] in rows in dataframe? There are many nested arrays such as below. Any help would be appreciated. Thank you. Just to make things easier, I want to create each array as rows in dataframe. Example for the first array needs to be laid out like this in dataframe *-0.14091441, 0.02556057, 0.10425788, ..., -0.03699904, 0.00503982, 0.08761989 So far I have tried :
pd.concat([pd.DataFrame(arrays_list[i][0]) for i in range(len(arrays_list))]).reset_index(drop=False)
arrays_list being my nested arrays.
[array([[[-0.14091441, 0.02556057, 0.10425788, ..., -0.03699904,
0.00503982, 0.08761989]],
[[-0.16227441, 0.03150389, 0.06440173, ..., -0.10543424,
0.05987305, 0.04117104]],
[[-0.11423473, 0.03741207, 0.0783961 , ..., -0.16773996,
0.06566695, 0.0683976 ]],
...,
[[-0.13789459, 0.05840103, 0.09803487, ..., -0.09256409,
0.01833008, 0.08413954]],
[[-0.12652887, 0.03683193, 0.06100509, ..., -0.06188103,
0.00915053, 0.09518969]],
[[-0.19781192, 0.05750425, 0.14811654, ..., -0.10550601,
0.05405622, 0.13771409]]]),
array([[[-0.0375578 , 0.16006446, 0.07978896, ..., -0.0883253 ,
0.0057608 , 0.07953031]],
[[ 0.00282089, 0.18854009, 0.01686837, ..., -0.02981209,
-0.01220972, 0.02810074]],
[[ 0.0333602 , 0.21895081, 0.05255894, ..., -0.01882036,
-0.03316848, 0.02506595]],
...,
[[-0.02498044, 0.17067145, 0.03956907, ..., -0.00617604,
0.01254308, 0.03375499]],
[[ 0.0333602 , 0.21895081, 0.05255894, ..., -0.01882036,
-0.03316848, 0.02506595]],
[[ 0.01105822, 0.20526624, 0.05087842, ..., -0.0442748 ,
-0.08184794, 0.04356682]]]),
array([[[-1.16298698e-01, 6.60857707e-02, 4.37349118e-02, ...,
5.65935597e-02, 1.17720775e-01, 4.68457118e-02]],
[[-1.70329705e-01, 7.15664029e-02, 2.13463139e-02, ...,
8.40441436e-02, 3.38792875e-02, -9.66352411e-04]],
[[-1.38925180e-01, 6.48617744e-02, 7.50765130e-02, ...,
3.60708833e-02, 9.37591046e-02, 3.88324559e-02]],
...,
[[-1.38925180e-01, 6.48617744e-02, 7.50765130e-02, ...,
3.60708833e-02, 9.37591046e-02, 3.88324559e-02]],
[[-1.55961111e-01, 7.59401619e-02, 3.65645029e-02, ...,
9.78165418e-02, 9.37420279e-02, 5.14532737e-02]],
[[-1.19004108e-01, 6.59743100e-02, 7.72421211e-02, ...,
4.89978008e-02, 1.33881345e-04, 2.18758285e-02]]])]
For the purpose of this question here is an analogous mre.
from numpy.random import default_rng
rng = default_rng()
a = rng.integers(0,5,(6,1,6))
b = rng.integers(0,5,(6,1,6))
c = rng.integers(0,5,(6,1,6))
# or just
# np.random.randint(0,5,(6,1,6))
obj = [a,b,c]