Skip to content

Instantly share code, notes, and snippets.

@utahka
Created July 9, 2018 10:39
Show Gist options
  • Save utahka/d5f93ca0b912f0e433e789c59929b33e to your computer and use it in GitHub Desktop.
Save utahka/d5f93ca0b912f0e433e789c59929b33e to your computer and use it in GitHub Desktop.
import numpy as np
def intersect2d(x, y):
_, ncols = x.shape
dtype = {
"names": [f"f{i}" for i in range(ncols)],
"formats": ncols * [predict.dtype],
}
intersect = np.intersect1d(x.view(dtype), y.view(dtype))
intersect = intersect.view(x.dtype).reshape(-1, ncols)
return intersect
@utahka
Copy link
Author

utahka commented Jul 9, 2018

Numpy intersect2d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment