鉴于此CSV文件:
"A","B","C","D","E","F","timestamp"
611.88243,9089.5601,5133.0,864.07514,1715.37476,765.22777,1.291111964948E12
611.88243,9089.5601,5133.0,864.07514,1715.37476,765.22777,1.291113113366E12
611.88243,9089.5601,5133.0,864.07514,1715.37476,765.22777,1.291120650486E12
我只是想将其加载为3行7列的矩阵/ ndarray。但是,由于某种原因,我能从numpy中得到的只有一个具有3行(每行一个)且没有列的ndarray。
r = np.genfromtxt(fname,delimiter=',',dtype=None, names=True)
print r
print r.shape
[ (611.88243, 9089.5601000000006, 5133.0, 864.07514000000003, 1715.3747599999999, 765.22776999999996, 1291111964948.0)
(611.88243, 9089.5601000000006, 5133.0, 864.07514000000003, 1715.3747599999999, 765.22776999999996, 1291113113366.0)
(611.88243, 9089.5601000000006, 5133.0, 864.07514000000003, 1715.3747599999999, 765.22776999999996, 1291120650486.0)]
(3,)
我可以手动迭代并将其修改为所需的形状,但这似乎很愚蠢。我只想将其加载为适当的矩阵,以便可以像在matlab中一样将其切成不同的维度并绘制出来。