# numpy.setxor1d() function in Python

`numpy.setxor1d()` function find the set exclusive-or of two arrays and return the sorted, unique values that are in only one (not both) of the input arrays.

Syntax : numpy.setxor1d(arr1, arr2, assume_unique = False)

Parameters :
arr1, arr2 : [array_like] Input arrays.
assume_unique : [bool] If True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False.

Return : [ndarray] Sorted 1D array of unique values that are in only one of the input arrays.

Code #1 :

 `# Python program explaining ` `# numpy.setxor1d() function ` `   `  `# importing numpy as geek  ` `import` `numpy as geek  ` `  `  `arr1 ``=` `[``1``, ``2``, ``3``, ``4``] ` `arr2 ``=` `[``2``, ``4``, ``6``, ``8``] ` `  `  `gfg ``=` `geek.setxor1d(arr1, arr2) ` `  `  `print` `(gfg) `

Output :

```[1 3 6 8]
```

Code #2 :

 `# Python program explaining ` `# numpy.setxor1d() function ` `   `  `# importing numpy as geek  ` `import` `numpy as geek  ` `  `  `arr1 ``=` `[``1``, ``2``, ``3``, ``4``, ``5``] ` `arr2 ``=` `[``-``2``, ``-``1``, ``0``, ``1``, ``2``] ` `  `  `gfg ``=` `geek.setxor1d(arr1, arr2) ` `  `  `print` `(gfg) `

Output :

```[-2 -1  0  3  4  5]
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.