我有一系列称为dists的距离.我想选择两个值之间的dists.我写了以下代码行来做到这一点:
dists[(np.where(dists >= r)) and (np.where(dists <= r + dr))]
Run Code Online (Sandbox Code Playgroud)
但是,这仅选择条件
(np.where(dists <= r + dr))
Run Code Online (Sandbox Code Playgroud)
如果我通过使用临时变量顺序执行命令,它可以正常工作.为什么上面的代码不起作用,我如何让它工作?
干杯
I am trying to search in a 2D numpy array for a specific value, the get_above method returns a list of coordinates above the character 'initial char'
def get_above(current, wordsearch):
list_of_current_coords = get_coords_current(current, wordsearch)
#print(list_of_current_coords)
length = len(list_of_current_coords)
first_coords = []
second_coords = []
for x in range(length):
second = list_of_current_coords[x][1]
new_first = list_of_current_coords[x][0] - 1
first_coords.append(new_first)
second_coords.append(second)
combined = [first_coords, second_coords]
above_coords = []
for y in range(length):
lst2 = [item[y] for item in combined]
above_coords.append(lst2)
return above_coords
def …Run Code Online (Sandbox Code Playgroud)