import matplotlib.pyplot as xy
a= [1,3,5,3,'',4]
b=[1,2,3,4,5,6]
xy.plot(b,a)
xy.show()
这段代码报错并提示 "ValueError: could not convert string to float:"
import matplotlib.pyplot as xy
a= [1,3,5,3,'',4]
b=[1,2,3,4,5,6]
xy.plot(b,a)
xy.show()
这段代码报错并提示 "ValueError: could not convert string to float:"
a
和b
中的数据而不会引起任何问题。如有疑问,请在执行for
循环之前对两者进行复制。a=[1,3,5,3,'',4]
b=[1,2,3,4,5,6]
for index in range(len(a)-1):
if a[index] is '':
del a[index]
del b[index]
np.nan
,而不是''
。 - tacaswell