Python错误16.06.05或:float()的文字无效:28.6521

时间:2015-06-17 13:27:55

标签: python

这是我的代码:

[
    {type:"a", index:0, value:0.1},
    {type:"a", index:1, value:0.2},
    ...
]

并使用此表:

import scipy.stats.stats 
import datetime
import numpy
import matplotlib.pyplot as plt
from scipy.stats.stats 
import pearsonr

file= u"C:/Users/Nikita/Desktop/file.csv"
with open(file) as f:
 rows = [line.strip().split(';') for line in f][:2482]

dates = [row[0] for row in rows]
dates = [datetime.datetime.strptime(d, "%d.%m.%y") for d in dates] 
dol = [float(row[1]) for row in rows]
val = [float(row[2]) for row in rows]
plt.plot_date(dates, val, fmt='b-')
plt.plot_date(dates, dol, fmt='r-')
plt.figure()
plt.show()

win=1000
depen = []
for i in range(len(val)):
 lo=max(0, i-win)
 hi=min(len(val)-1, i+win)
 depen.append(scipy.stats.stats.pearsonr(val[i-win:i+win], dol[i-win:i+win])[0])
print (depen)
plt.plot_date(dates, depen, fmt='r-')
plt.figure()
ply.show() 

addepend = pearsonr(val, dol)[0]
print (addepend)
print (numpy.corrcoef(val, dol)[0, 1])

有什么问题?

15.06.05    10566.37      28.6521
16.06.05    10578.65      28.6275
17.06.05    10623.07      28.6024
18.06.05    10609.11      28.5841
21.06.05    10599.67      28.4765
22.06.05    10587.93      28.5497
23.06.05    10421.44      28.5528
etc.

0 个答案:

没有答案