我有一组列中的数据,其中第一列是 x 值。我怎么读这个?
问问题
92 次
1 回答
0
如果你想同时存储x
和y
值,你可以做
ydat = np.zeros((data.shape[1]-1,data.shape[0],2))
# write the x data
ydat[:,:,0] = data[:,0]
# write the y data
ydat[:,:,1] = data[:,1:].T
编辑:如果您只想将 y 数据存储在子数组中,您可以简单地执行
ydat = data[:,1:].T
工作示例:
t = np.array([[ 0., 0., 1., 2.],
[ 1., 0., 1., 2.],
[ 2., 0., 1., 2.],
[ 3., 0., 1., 2.],
[ 4., 0., 1., 2.]])
a = t[:,1:].T
a
array([[ 0., 0., 0., 0., 0.],
[ 1., 1., 1., 1., 1.],
[ 2., 2., 2., 2., 2.]])
于 2015-04-29T16:58:34.167 回答