I am looking for a way to convert an array of strings in numpy to the integers they represent in hexadecimal. So in other words, the array version of:
int("f040", 16)
I can convert a string array to integers base-10 by calling arr.astype(numpy.int32), but I can't see any obvious way to convert them base-16. Does anyone know of a way to do this?
ar = ['f040', 'deadbeaf']
int_array = [int(a, 16) for a in ar]
print int_array
output:
[61504, 3735928495L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With