如何将嵌套的 np.array 转换为 pandas 数据框单列
Posted
技术标签:
【中文标题】如何将嵌套的 np.array 转换为 pandas 数据框单列【英文标题】:how to convert the nested np.array into the pandas dataframe single column 【发布时间】:2019-06-22 01:13:41 【问题描述】:我想将此嵌套数组转换为单个 pandas 数据框列,我该怎么做?谁能帮帮我?
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]) ])
熊猫单栏:
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】:也许可以试试concatenate
pd.Series(np.concatenate(a))
【讨论】:
以上是关于如何将嵌套的 np.array 转换为 pandas 数据框单列的主要内容,如果未能解决你的问题,请参考以下文章