【发布时间】:2021-07-10 23:44:24
【问题描述】:
我在运行程序时生成了一个变量,它的类型是series,内容如下所示。可以看出test_prior是一个系列,其中每个系列元素也是一个系列。如何检索这些元素系列并将它们保存到 numpy 数组中。或者,是否可以将其系列(即test_prior)保存到矩阵中?
type(test_prior)
pandas.core.series.Series
test_prior
0 [0.0032125000000000005, 0.003213987572590001, ...
1 [0.0037124999999999997, 0.00371353755063, 0.00...
2 [0.0003125, 0.0003170377214300023, 0.000321575...
3 [0.0048625, 0.004865587650670002, 0.0048686753...
4 [0.0020875, 0.0020882125347700003, 0.002088925...
...
195 [0.0010625, 0.0010631875335500003, 0.001063875...
196 [0.0009875, 0.0009895876018700012, 0.000991675...
197 [0.0024375, 0.0024401126274900013, 0.002442725...
198 [0.0022375, 0.0022403376384700015, 0.002243175...
199 [0.0005125, 0.000514487596990001, 0.0005164751...
Length: 200, dtype: object
【问题讨论】:
-
元素可能是列表,也可能是 numpy 数组。你看过
test_prior.values吗? -
同意,它们看起来像列表/数组,而不是系列。检查
type(test_prior[0]) -
type(test_prior) 是 numpy.ndarray
标签: python python-3.x pandas numpy scipy