Linked Questions
10 questions linked to/from test for membership in a 2d numpy array
1 vote
1 answer
892 views
how to find indices of a 2d numpy array occuring in another 2d array [duplicate]
I have two 2d numpy arrays and want to find where one array is occuring in another one: big_array = np.array([[1., 2., 1.2], [5., 3., 0.12], [-1., 14., 0.], [-9., 0., 13.]]) small_array= np.array([[5.,...
4 votes
2 answers
11k views
Build a color palette from image URL
I am trying to create an API which takes an image URL as input and returns back a color palette in JSON format as output. It should work something like this: http://lokeshdhakar.com/projects/color-...
3 votes
2 answers
4k views
Fast way to find index of array in array of arrays
Suppose I have a numpy array of arrays of length 4: In [41]: arr Out[41]: array([[ 1, 15, 0, 0], [ 30, 10, 0, 0], [ 30, 20, 0, 0], ..., [104, 139, 146, 75]...
0 votes
3 answers
1k views
Numpy Find Indices of Common Points in 2D Array
System OS: Windows 10 (x64), Build 1909 Python Version: 3.8.10 Numpy Version: 1.21.2 Question Given two 2D (N, 3) Numpy arrays of (x, y, z) floating-point data points, what is the Pythonic (vectorized)...
2 votes
2 answers
618 views
Match rows of two 2D arrays and get a row indices map using numpy
Suppose you have two 2D arrays A and B, and you want to check, where a row of A is contained in B. How do you do this most efficiently using numpy? E.g. a = np.array([[1,2,3], [4,5,6],...
0 votes
2 answers
716 views
Match on multiple columns using array
I'm working on a project where my original dataframe is: A B C label 0 1 2 2 Nan 1 2 4 5 7 2 3 6 5 Nan 3 4 8 7 Nan 4 5 ...
0 votes
2 answers
334 views
Find indices of unique common values inside two unsorted 2d arrays of unique numbers
In other words, I need to define the index correspondence between equal unique numbers inside two unsorted 2d arrays. Similar questions: how to find indices of a 2d numpy array occuring in another 2d ...
1 vote
3 answers
108 views
comparing two numpy arrays and adding same rows
I have two large data files, one with two columns and one with three columns. I want to select all the rows from the second file that are contained in the fist array. My idea was to compare the numpy ...
1 vote
2 answers
103 views
Difrerent rows in two numpy arrays
I want to filter out elements of a 2d list from another 2d list c = (array([1, 1, 1, 1]), array([2, 3, 4, 5])) b = [[1 1 1 1] [2 3 4 5] [2 3 4 1] [4 5 6 7]] a = itertools.filterfalse(lambda x: x ...
0 votes
1 answer
25 views
ndarray assignment where value is in a set is unhashable
I've got an ndarray myndarray and a set myset. I can do this: myndarray[myndarray[:,:,-1] == some_value] = 0 But this returns "unhashable type: 'numpy.ndarray'" myndarray[myndarray[:,:,-1] ...