How To Save Subarray In Npy File?
My data tracks has following shape : (13044,) Its data types are tracks.dtype.names ('frame_num','mean_x','mean_y','var_x','var_y', 'length', 'scale', 'x_pos','y_pos', 't_pos',
Solution 1:
You can save a numpy array of all of your (16,2) y's:
ys = []
for i in range(len(tracks)):
y=tracks['coords'][i]
ys.append(y)
print(y)
np.save('test.npy',np.array(ys))
Also note that you are traversing along tracks
with i
, but reading tracks['coord'][i]
each time (could be different lengths). In addition, if not all y's are in the same length than it would be a problem to create a numpy array out of them, but you can still save a list through np.save
and when loading them use np.load('test.npy').item()
(again, if you're not saving them as np.array
).
Post a Comment for "How To Save Subarray In Npy File?"