输入 csv 文件:
a,b,c,d,e
1,2,3,4,2
3,4,5,6,3
3,4,5
1,2
代码:
import numpy as np
data = np.genfromtxt("sa.csv", dtype=None, delimiter=',', names=True)
print data['a'],data['b'],data['e']
我会得到一个错误
Traceback (most recent call last):
File "cs.py", line 3, in <module>
data = np.genfromtxt("sa.csv", dtype=None, delimiter=',', names=True)
File "/usr/lib/python2.7/dist-packages/numpy/lib/npyio.py", line 1593, in genfromtxt
raise ValueError(errmsg)
ValueError: Some errors were detected !
Line #4 (got 3 columns instead of 5)
Line #5 (got 2 columns instead of 5)
如何处理这个问题并使用python中的statsmodels根据所选列执行关联?