Numpy. Compare All Vector Row In One Array With Every Other One In The Same Array
I have a numpy array as below: a= array([[2, 3], [0, 2]]) and want to compare 'vectors' in each row with every other rows, using np.greater, so to have: array([[False, False],
Solution 1:
Try this:
a[:,np.newaxis] > a
It is the same as this more explicit code:
a[:,np.newaxis,:] > a[np.newaxis,:,:]
Hat tip to https://stackoverflow.com/a/16500609/4323
Details on what it does: The use of Python numpy.newaxis
Post a Comment for "Numpy. Compare All Vector Row In One Array With Every Other One In The Same Array"