【发布时间】:2018-04-23 05:09:28
【问题描述】:
好的,所以我在 python 中有一个数组。该数组保存另一个数组的索引。我从这个数组中删除了我想保留的索引。
stations = [1,2,3]
让我们调用x 主数组。它有 5 列,我删除了第 1 列和第 5 列,并将其余部分放入名为 stations 的数组中。
我希望能够创建一个 if 语句,其中排除来自站的值。所以我只是想找出站数组中的索引为 0 而其他索引(0 和 4)不为 0 的实例数(天数)。
我该怎么做呢?到目前为止我有这个,但它似乎不正确。
for j in range(len(x)):
if x[j,0] != 0 and x[j,4] != 0 and numpy.where(x[j,stations[0]:stations[len(stations)-1]]) == 0:
days += 1
return days
【问题讨论】:
标签: python arrays numpy boolean where