ValueError: could not convert string to float: (large string)

ValueError: could not convert string to float: (large string)

感谢您的帮助!!!!我快到了! 我有一组数据,我正在尝试将其绘制成图表,目前只是针对连续的整数,稍后一旦我有了这个工作,就会针对时间。

for a in Data['result'][:1]:      #only print the first result in the list
        #print a['value']


    Data_clean = a['value'].replace('0,','0.') 
    Data_list = Data_clean.split(',')

T2 = [map(float, x) for x in Data_list]   #turn string into integer so that it                
                                           #can be graphed

print T2

但出现以下错误

  T2 = [map(float, x) for x in Data_list]

ValueError: could not convert string to float: 

Data_list 看起来像这样

[u'-0.04149', u'-0.03866', u'-0.02914', u'-0.02319', u'-0.02027', u'-0.00234', u'0.00564', u'0.01269', u'0.02852', u'0.04648', u'0.05709', u'0.06261', u'0.07325', u'0.08223', u'0.08665']

如果我理解你的目标你正试图将它转换成 bad.manner 中的浮点数(不是整数),就像混合策略一样,你可以改为这样做:

T2 = map(float, Data_list)
#or
T2 = [float(x) for x in Data_list]

这是你想要的吗?