用 np.array 中的值填充数据框列

问题描述 投票:0回答:1

我有一个数据框 (enter image description here),其中一列标记为“dist”。对于每个“dist”值(数组 a),我计算了一个存储在数组 (b) 中的度量。

现在,我想将这些 b 值添加到我的数据框中 (enter image description here)。

pandas numpy unique
1个回答
0
投票

您可以使用

c_[]
来做到这一点:

import numpy as np
a_array = [....] 
b_array = [....]

np.c_[a_array, b_array]

文档:https://numpy.org/doc/stable/reference/generated/numpy.c_.html

© www.soinside.com 2019 - 2024. All rights reserved.