If you have a dictionary where the keys are strings and the values ββare arrays, for example:
>>> import numpy >>> arrs = {'a': numpy.array([1,2]), 'b': numpy.array([3,4]), 'c': numpy.array([5,6])}
You can use numpy.savez to save them by keyword into a compressed file:
>>> numpy.savez('file.npz', **arrs)
To download it back:
>>> npzfile = numpy.load('file.npz') >>> npzfile <numpy.lib.npyio.NpzFile object at 0x1fa7610> >>> npzfile['a'] array([1, 2]) >>> npzfile['b'] array([3, 4]) >>> npzfile['c'] array([5, 6])
source share