我有一个像这样的 Pandas 系列:
measure
0 0.3
6 0.6
9 0.2
11 0.3
14 0.0
17 0.1
23 0.9
和一个像这样的 numpy 数组:
array([[ 0, 0, 9, 11],
[ 6, 14, 6, 17]])
我如何从 numpy 数组中的值到系列中的索引进行查找以获取此信息:
array([[ 0.3, 0.3, 0.2, 0.3],
[ 0.6, 0.0, 0.6, 0.1]])
最佳答案
通过 np.vectorize
,使用系列 s
和数组 a
:
np.vectorize(s.get)(a)
关于python - 如何将 Pandas 查找表应用于 numpy 数组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48554344/