Helicity
Helicity

Reputation: 127

ValueError: could not convert string to float, (numpy.string_)

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

Answers (1)

Helicity
Helicity

Reputation: 127

Row [0] had blank characters...

Upvotes: 1

Related Questions