0

I have a list of coordinates among other things, I want to delete the number of objects I have in, say, quadrant I. I tried using np.delete, but perhaps my loop is wrong since it only deletes one single object. Here's what I have so far:

import sys
import os
import numpy as np
from pylab import *
import scipy
def get_distance(x,y,x_center,y_center):
  d = (x - x_center)**2 + (y - y_center)**2
  d = sqrt(d)
return d

dataA=np.genfromtxt('match.txt')
c1=dataA[:,0]
c2=dataA[:,1]
d1=dataA[:,2]
d2=dataA[:,3]

for i in xrange(len(c1)):
   if c1[i] >= 0 and c1[i] <= 2288 and c2[i] >= 2288 and c2[i] <= 4576:
      new_a = np.delete(c1,i)
      new_b = np.delete(c2,i)

1 Answer 1

1

In your for loop build a list of i's that need to be deleted (e.g. del_list). Once you are done with the loop, you can delete the list of i's from c1 and c2

new_a = np.delete(c1, del_list)
new_b = np.delete(c2, del_list)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.