I was writing this code to make some data graphs on my jupyter notebook, and when I tried bringing in data from a csv file, I got a "could not convert string to float" error.
So here's my code:
phot_g = np.genfromtxt('gaia_hyades_search.csv', dtype='str', delimiter=",", skip_header=1, usecols=(6), unpack=True)
phot_bp = np.genfromtxt('gaia_hyades_search.csv', dtype='str', delimiter=",", skip_header=1, usecols=(7), unpack=True)
phot_rp = np.genfromtxt('gaia_hyades_search.csv', dtype='str', delimiter=",", skip_header=1, usecols=(8), unpack=True)
phot_g = phot_g.astype(np.float64)
phot_bp = phot_bp.astype(np.float64)
phot_rp = phot_rp.astype(np.float64)
And here's my error:
ValueError Traceback (most recent call last)
/tmp/ipykernel_63/3948901710.py in <module>
---> 18 phot_g = phot_g.astype(np.float64)
19 phot_bp = phot_bp.astype(np.float64)
20 phot_rp = phot_rp.astype(np.float64
ValueError: could not convert string to float: ''
I've tried searching the error up, but a lot of the solutions I've gotten have been for numpy.loadtxt, and moreover, they don't seem to help me at all. Any help would be greatly appreciated.
By the way, the error shows up for all three lines of code (phot_g, phot_bp, and phot_rp)