Skip to content

Instantly share code, notes, and snippets.

@brantfaircloth
Last active December 21, 2015 15:59
Show Gist options
  • Save brantfaircloth/6330209 to your computer and use it in GitHub Desktop.
Save brantfaircloth/6330209 to your computer and use it in GitHub Desktop.
casting a numpy array of strings to int (examples)
import numpy
s = '40 40 40 40 40'
sl = s.rstrip().split(' ')
si = [int(elem) for elem in sl]
sa = numpy.array(si)
import numpy
s = '40 40 40 40 40'
sa = numpy.array(s.rstrip().split(' ')).astype(int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment