0

我正在使 mu 代码更好,我看到 numpy 已经内置了一些非常漂亮的功能。但是,以下代码会引发我无法解释的错误:

data = numpy.genfromtxt('table.oout',unpack=True,names=True,dtype=None)

real_ov_data=np.float32(data['real_overlap'])
ana_ov_data= np.float32(data['Analyt_overlap'])
length_data =np.float32(data['Residues'])

plot(length_data,real_ov_data,label="overlapped Peaks, exponential function",marker="x", markeredgecolor="blue", markersize=3.0, linestyle=" ",color="blue")
plot(length_data,ana_ov_data,label="expected overlapped Peaks",marker="o", markeredgecolor="green", markersize=3.0, linestyle=" ",color="green")

抛出错误

Traceback (most recent call last):
  File "length_vs_overlap.py", line 52, in <module>
    real_ov_data=np.float32(data['real_overlap'])
ValueError: invalid literal for float(): real_overlap
>Exit code: 1

当我试图阅读以下文件时:

  'Residues'  'Analyt_overlap'  'anz_analyt_overlap'  'real_overlap' 
  21          1.2502        29            0.0000  
  13          1.0306        25            0.0000  
  56          5.8513        84            2.8741  
  190         68.0940       329           28.4706 
  54          5.4271        83            2.4999  

我究竟做错了什么?我的一段代码应该够简单吧?

4

1 回答 1

1

您要么重复了标题行,要么将 指定names为列表。

这导致每列都被读取为以列标题开头的字符串类型。

于 2012-06-28T16:12:08.763 回答