ValueError: failed to convert string to float: plotting in python
I imported a csv file that contains decimal numbers with exponents, for example (5.5006250364943992 ** 02). I keep getting ValueError: could not convert string to float
. This is what I did:
import matplotlib.pyplot as plt
import csv
x = []
y = []
with open('DNSdata.csv', 'r') as csvfile:
plots = csv.reader(csvfile, delimiter=',')
for row in plots:
x.append(float(row[0]))
y.append(float(row[1]))
plt.plot(x, y, label='DNSdata')
plt.xlabel('x')
plt.ylabel('y')
plt.title('DNSdata')
plt.show()
+3
source to share