NumPy
numpy.org › doc › stable › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v2.5 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.intersect1d([1, 3, 4, 3], [3, 1, 2, 1]) array([1, 3]) To intersect more than two arrays, use functools.reduce: >>> from functools import reduce >>> reduce(np.intersect1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])) arra
NumPy
numpy.org › doc › 2.2 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v2.2 Manual
>>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) >>> x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], y[y_ind] (array([1, 2, 4]), array([1, 2, 4]), array([1, 2, 4]))
NumPy
numpy.org › doc › 2.3 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v2.3 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.intersect1d([1, 3, 4, 3], [3, 1, 2, 1]) array([1, 3]) To intersect more than two arrays, use functools.reduce: >>> from functools import reduce >>> reduce(np.intersect1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])) arra
NumPy
numpy.org › devdocs › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v2.6.dev0 Manual
Examples · Try it in your browser! >>> import numpy as np >>> np.intersect1d([1, 3, 4, 3], [3, 1, 2, 1]) array([1, 3]) To intersect more than two arrays, use functools.reduce: >>> from functools import reduce >>> reduce(np.intersect1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])) arra
SciPy
docs.scipy.org › doc › numpy-1.13.0 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v1.13 Manual
June 10, 2017 - >>> from functools import reduce >>> reduce(np.intersect1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])) array([3])
Studyopedia
studyopedia.com › home › intersection of numpy arrays
Intersection of Numpy Arrays - Studyopedia
March 30, 2026 - import numpy as np # Create two ... print(a) print("\nIterating array2...") for a in n2: print(a) # Find the intersection resarr = np.intersect1d(n1, n2) print("\nIntersection (different elements) = \n", resarr)...
ProgramCreek
programcreek.com › python › example › 102202 › numpy.intersect1d
Python Examples of numpy.intersect1d
def intersect_sim(array_1, array_2): """Calculate the simiarity of two arrays by using intersection / union """ sim = float(np.intersect1d(array_1, array_2).size) / \ float(np.union1d(array_1, array_2).size) return sim ... def remove(self, prop, indices): if prop in self._properties: diff = ...
NumPy
numpy.org › doc › 2.0 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v2.0 Manual
>>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) >>> x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], y[y_ind] (array([1, 2, 4]), array([1, 2, 4]), array([1, 2, 4]))
NumPy
numpy.org › doc › 1.22 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v1.22 Manual
>>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) >>> x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], y[y_ind] (array([1, 2, 4]), array([1, 2, 4]), array([1, 2, 4]))
NumPy
numpy.org › doc › 1.18 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v1.18 Manual
May 24, 2020 - >>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) >>> x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], y[y_ind] (array([1, 2, 4]), array([1, 2, 4]), array([1, 2, 4]))
Pydocs
pydocs.github.io › p › numpy › 1.22.4 › api › numpy.intersect1d.html
intersect1d
>>> x = np.array([1, 1, 2, 3, 4]) ... y = np.array([2, 1, 4, 6]) ... xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) ... x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], y[y_ind] (array([1, 2, 4]), array([1, 2, 4]), array([1, 2, 4])) See : The following pages refer to to this document either explicitly or contain code examples using this. numpy.ma.extras.intersect1d ·
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.ma.intersect1d.html
numpy.ma.intersect1d — NumPy v2.1 Manual
>>> import numpy as np >>> x = np.ma.array([1, 3, 3, 3], mask=[0, 0, 0, 1]) >>> y = np.ma.array([3, 1, 1, 1], mask=[0, 0, 0, 1]) >>> np.ma.intersect1d(x, y) masked_array(data=[1, 3, --], mask=[False, False, True], fill_value=999999)
SciPy
docs.scipy.org › doc › numpy-1.10.1 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v1.10 Manual
>>> from functools import reduce >>> reduce(np.intersect1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])) array([3])
TutorialsPoint
tutorialspoint.com › numpy › numpy_intersection.htm
NumPy - Intersection
However, the function compares the elements based on their data types, meaning it performs type-sensitive matching. In this example, the intersection element 4 is returned as a float because the first array contains floating-point numbers −
NumPy
numpy.org › doc › 1.16 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v1.16 Manual
To return the indices of the values common to the input arrays along with the intersected values: >>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) >>> x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], ...
NumPy
numpy.org › doc › 2.1 › reference › generated › numpy.intersect1d.html
numpy.intersect1d — NumPy v2.1 Manual
>>> x = np.array([1, 1, 2, 3, 4]) >>> y = np.array([2, 1, 4, 6]) >>> xy, x_ind, y_ind = np.intersect1d(x, y, return_indices=True) >>> x_ind, y_ind (array([0, 2, 4]), array([1, 0, 2])) >>> xy, x[x_ind], y[y_ind] (array([1, 2, 4]), array([1, 2, 4]), array([1, 2, 4]))
TutorialsPoint
tutorialspoint.com › numpy › numpy_intersect1d_function.htm
Numpy intersect1d() Function
Following are the parameters of the Numpy intersect1d() function − ... assume_unique (optional): If True, the input arrays are assumed to be unique, which can speed up the calculation. Default is False. return_indices (optional): If True, the indices of the shared elements in the original arrays are returned as additional outputs. Default is False. This function returns a sorted 1D array containing unique elements present in both input arrays. Following is a basic example of finding the intersection of two arrays using the Numpy intersect1d() function −