我有一个大约 7 列的 Numpy 数组,我需要对某些值进行很多索引,但目前我这样做的方式并不容易阅读。例如。我想说什么rates[-1][high]
或类似的话。我想也许我可以为例如做变量。high = 2
但是我在许多不同的函数中使用相同的费率数据,所以我必须在每个函数中设置这些变量或将它们作为参数传递,但这也不是很有用。有一个更好的方法吗?提前致谢!
if (
rates[-1][4] > rates[-1][1]
and rates[-2][4] > rates[-2][1]
and rates[-1][4] > rates[-2][4]
):