Skip to content

Instantly share code, notes, and snippets.

@albarrentine
Created May 2, 2012 14:43
Show Gist options
  • Save albarrentine/2577070 to your computer and use it in GitHub Desktop.
Save albarrentine/2577070 to your computer and use it in GitHub Desktop.
Numpy set APIs
import numpy
a = numpy.arange(10)
b = numpy.arange(5, 15)
numpy.setdiff1d(a,b) # array([0, 1, 2, 3, 4])
numpy.union1d(a,b) # array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
numpy.intersect1d(a,b) # array([5, 6, 7, 8, 9])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment