获取搜索结果的索引

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

下面的代码获取匹配值的索引:

x = ["Moon", "Earth", "Jupiter", "Neptune", "Earth", "Venus"]
get_indexes = lambda x, xs: [i for (y, i) in zip(xs, range(len(xs))) if x == y]
print(get_indexes("Earth", x))

下面的代码提取满足条件的峰值:

intensitySortedPeaks = sorted(peaks, key=lambda p: p.Intensity, reverse=True)
for i in range(len(intensitySortedPeaks)):
    testMass = intensitySortedPeaks[i].MZ + 1.0033
    results = [p for p in intensitySortedPeaks if abs(GetPPMError(p.MZ,testMass)) < 10]
 ###how do we get the indexes saved as indeResults

如何获取存储在结果变量中的元素的索引。我想从循环中的原始intensitySortedList中删除这些元素

如何修改上面的代码来完成这个任务?

python numpy dataframe scipy
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.