Home > Back-end >  Retrieving an array from another array
Retrieving an array from another array

Time:11-11

I have an array consisting of the coordinates (x,y) of certain points. I want to get an array consisting ONLY of the co-ordinates that have -0.1 <= x <= 1.1 and simultaneously -0.1 <= y <= 1.1. I have very little experience with Python, do you have any ideas?

x_right = np.array[: , 1]
for vor.vertices in coords:
    if (-0.1 <= vor.vertices[0,:] <= 1.1):
        x_right.append([vor.vertices[0]],[])
xy_right = [x_right.append(i[0]),[]]
for j[1] in x_right:
    if (-0.1 <= j[1] <= 1.1):
        xy_giuste = [x_giuste.append(i[0]), J[1] ]

CodePudding user response:

example_points = [(.4,.5),(3,4),(.5,1)]
resulting_points = [(x,y) for (x,y) in example_points if -0.1<=x<=1.1 and -0.1<=y<=1.1]
print(resulting_points)

This returns a list with the points (0.4,0.5) and (0.5,1) is this what you want?

  • Related