【发布时间】:2021-01-28 04:34:20
【问题描述】:
我正在尝试使用 numpy 编写代码,它输出索引之间的最大值。我认为使用argmax 可能是可用的。但是我不知道如何在不使用 python 循环的情况下使用切片。如果有一个熊猫功能,它也可以使用。我想让计算尽可能快。
list_ = np.array([9887.89, 9902.99, 9902.99, 9910.23, 9920.79, 9911.34, 9920.01, 9927.51, 9932.3, 9932.33, 9928.87, 9929.22, 9929.22, 9935.24, 9935.24, 9935.26, 9935.26, 9935.68, 9935.68, 9940.5])
indexes = np.array([0, 5, 10, 19])
预期结果:
Max number between index(0 - 5): 9920.79 at index 5
Max number between index(5 - 10): 9932.33 at index 10
Max number between index(10 - 19): 9940.5 at index 19
【问题讨论】: