鉴于此 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 中一样。