DEV Community

Punitha
Punitha

Posted on

Set Operations

  • NumPy provides functions for set-like operations on arrays.
  • union1d()
  • intersect1d()
  • setxor1d()
  • setdiff1d()

What is Union?

  • Union returns the unique values present in either array.

Step 1:

Output:

What is Intersection?

  • Intersection returns the values common to both arrays.

Step 1:

Output:

What is Set Difference?

  • setdiff1d() returns values that exist in the first array but not in the second.

Step 1:

Output:

What is Set XOR?

  • setxor1d() returns values that are in either array but not in both.

Step 1:

Output:

Top comments (0)