numpy.savez_compressed
- 
numpy.savez_compressed(file, *args, **kwds)[source] - 
Save several arrays into a single file in compressed
.npzformat.Provide arrays as keyword arguments to store them under the corresponding name in the output file:
savez(fn, x=x, y=y).If arrays are specified as positional arguments, i.e.,
savez(fn, x, y), their names will bearr_0,arr_1, etc.- Parameters
 - 
- 
filestr or file - 
Either the filename (string) or an open file (file-like object) where the data will be saved. If file is a string or a Path, the
.npzextension will be appended to the filename if it is not already there. - 
argsArguments, optional - 
Arrays to save to the file. Please use keyword arguments (see
kwdsbelow) to assign names to arrays. Arrays specified as args will be named “arr_0”, “arr_1”, and so on. - 
kwdsKeyword arguments, optional - 
Arrays to save to the file. Each array will be saved to the output file with its corresponding keyword name.
 
 - 
 - Returns
 - 
- None
 
 
See also
- 
 
numpy.save - 
Save a single array to a binary file in NumPy format.
 - 
 
numpy.savetxt - 
Save an array to a file as plain text.
 - 
 
numpy.savez - 
Save several arrays into an uncompressed
.npzfile format - 
 
numpy.load - 
Load the files created by savez_compressed.
 
Notes
The
.npzfile format is a zipped archive of files named after the variables they contain. The archive is compressed withzipfile.ZIP_DEFLATEDand each file in the archive contains one variable in.npyformat. For a description of the.npyformat, seenumpy.lib.format.When opening the saved
.npzfile withloadaNpzFileobject is returned. This is a dictionary-like object which can be queried for its list of arrays (with the.filesattribute), and for the arrays themselves.Examples
>>> 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–2021 NumPy Developers
Licensed under the 3-clause BSD License.
    https://numpy.org/doc/1.21/reference/generated/numpy.savez_compressed.html