Reputation: 127
I am trying to convert an array of np.string_
s that are all representing numbers into floats for mathematical use. I am reading data from a fits file using pyfits.
data = read_fits(datafile)
glon = np.asarray(data['GLON'], dtype = float); glat = data['GLAT']
# heliocentric distance in kpc
D = data['D']
for i in range(len(glon)):
#glon[i] = (glon[i]).astype(float)
I have left a couple of my attempts to change the type, but float() and all similar operations I have heard of are failing. Yet I do not think I have a bogus value as I have looked through a print
of the data after reading and it is all numerical.
Upvotes: 0
Views: 920