如何将嵌套的np.array转换为pandas dataframe单列

时间:2019-01-29 00:07:16

标签: arrays python-3.x pandas list numpy

我想将此嵌套数组转换为单个pandas dataframe列,我该怎么做?有人可以帮我吗?

    array([array([          nan,   16.40411828,   23.67187877,   27.19289145,
             31.48879139,   28.50329298,   25.16148811,   24.32455519,
             23.72071149,   22.96651751,   21.79875539,   21.05904285,
             20.65603351,   20.99366119,   21.52619114,   22.87522069,
             21.63331813,   21.93181362]),
           array([nan, 30.44444767, 29.96125493, 25.69240818, 23.96278846, 25.00461946, 24.78053007, 23.65561137, 23.9937393 , 24.06364734,
           26.85976645, 28.77707529, 30.45483929, 30.3066284 , 29.2685211 ,
           28.41220814, 27.22663736, 29.30175533]) 

array([nan, 30.44444767, 29.96125493, 25.69240818, 23.96278846, 25.00461946, 24.78053007, 23.65561137, 23.9937393 , 24.06364734,
           26.85976645, 28.77707529, 30.45483929, 30.3066284 , 29.2685211 ,
           28.41220814, 27.22663736, 29.30175533, 30.19692369, 26.90048144,
           24.29289412, 23.86300245, 22.48910863, 22.66028583, 22.25506455,
           22.26521476, 22.08912783, 23.05146134, 22.0568987 , 21.00369025,
           20.71023731, 19.48245301, 18.88289262]) ])

pandas单列:

0   NaN
1   30.444448
2   29.961255
3   25.692408
4   23.962788
5   25.004619
6   24.780530
7   23.655611
8   23.993739
9   24.063647
10  26.859766
11  28.777075
12  30.454839
13  30.306628
14  29.268521

1 个答案:

答案 0 :(得分:2)

也许尝试使用concatenate

pd.Series(np.concatenate(a))