gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 09:02:45 33 4
gpt4 key购买 nike

我想将此嵌套数组转换为单个 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]) ])

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

最佳答案

也许尝试使用连接

pd.Series(np.concatenate(a))

关于arrays - 如何将嵌套的 np.array 转换为 pandas dataframe 单列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54412081/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com