Quantcast
Browsing latest articles
Browse All 3 View Live

Answer by Alex Riley for NumPy: filter rows by np.array

Instead of using in, you can use np.in1d to check which values in the first column of ar are also in another_ar and then use the boolean index returned to fetch the rows of ar:>>>...

View Article


Answer by Mazdak for NumPy: filter rows by np.array

You can use np.where,but note that as ar[:,0] is a list of first elements if ar you need to loop over it and check for membership :>>> ar[np.where([i in another_ar for i in ar[:,0]])]array([[...

View Article


NumPy: filter rows by np.array

I'd like to filter a NumPy 2-d array by checking whether another array contains a column value. How can I do that?import numpy as npar = np.array([[1,2],[3,-5],[6,-15],[10,7]])another_ar =...

View Article
Browsing latest articles
Browse All 3 View Live