numpy.savez_compressed(file, *args, **kwds)
[source]
Save several arrays into a single file in compressed .npz
format.
If keyword arguments are given, then filenames are taken from the keywords. If arguments are passed in with no keywords, then stored file names are arr_0, arr_1, etc.
Parameters: |
|
---|---|
Returns: |
|
See also
numpy.save
numpy.savetxt
numpy.savez
.npz
file formatnumpy.load
The .npz
file format is a zipped archive of files named after the variables they contain. The archive is compressed with zipfile.ZIP_DEFLATED
and each file in the archive contains one variable in .npy
format. For a description of the .npy
format, see numpy.lib.format
.
When opening the saved .npz
file with load
a NpzFile
object is returned. This is a dictionary-like object which can be queried for its list of arrays (with the .files
attribute), and for the arrays themselves.
>>> test_array = np.random.rand(3, 2) >>> test_vector = np.random.rand(4) >>> np.savez_compressed('/tmp/123', a=test_array, b=test_vector) >>> loaded = np.load('/tmp/123.npz') >>> print(np.array_equal(test_array, loaded['a'])) True >>> print(np.array_equal(test_vector, loaded['b'])) True
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.savez_compressed.html