Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

set difference in multidimensional array numpy

>>> import numpy as np
>>> a1 = np.array([[1,2,3],[4,5,6],[7,8,9]])
>>> a2 = np.array([[4,5,6],[7,8,9],[1,1,1]])
>>> a1_rows = a1.view([('', a1.dtype)] * a1.shape[1])
>>> a2_rows = a2.view([('', a2.dtype)] * a2.shape[1])
>>> np.setdiff1d(a1_rows, a2_rows).view(a1.dtype).reshape(-1, a1.shape[1])
array([[1, 2, 3]])
Comment

PREVIOUS NEXT
Code Example
Python :: reverse relationship in django for one to one field for usage in Django rest serializer 
Python :: Roberta Inference TensorFlow 
Python :: python filter list 
Python :: interface in python 
Python :: List Comprehension build a list of tuples 
Python :: what is in the python built in namespace 
Python :: pyton count senteses in a text file 
Python :: python windows api 
Python :: filtering certain rows in python that contains a part of string 
Python :: remove rows from a dataframe that are present in another dataframe? 
Python :: how to do formatting in python with format function 
Python :: with open python print file name 
Python :: normalized histogram pandas 
Python :: pathlib check is file 
Python :: create an array filled with 0 
Python :: us states and capitals dictionary 
Python :: looping through the list 
Python :: how to omit days pandas datetime 
Python :: normal discord.py codes 
Python :: python string assignment by index 
Python :: python inspect 
Python :: flask run development mode 
Python :: Example pandas.read_hfd5() 
Python :: convert utm to decimal degrees python 
Python :: python binary tree search 
Python :: how to convert a matrix string back to a matrix python 
Python :: Access field values of form django 
Python :: size of int in python 
Python :: aiohttps 
Python :: check this id exist in database django 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =