numpy - Putting multiple columns into callable sub arrays python -
i have set of data in columns, first column x values. how read in?
if want store both, x
, y
values can do
ydat = np.zeros((data.shape[1]-1,data.shape[0],2)) # write x data ydat[:,:,0] = data[:,0] # write y data ydat[:,:,1] = data[:,1:].t
edit: if want store y-data in sub arrays can do
ydat = data[:,1:].t
working example:
t = np.array([[ 0., 0., 1., 2.], [ 1., 0., 1., 2.], [ 2., 0., 1., 2.], [ 3., 0., 1., 2.], [ 4., 0., 1., 2.]]) = t[:,1:].t array([[ 0., 0., 0., 0., 0.], [ 1., 1., 1., 1., 1.], [ 2., 2., 2., 2., 2.]])
Comments
Post a Comment