numpy.save

numpy.save(file, arr)

Save an array to a binary file in NumPy .npy format.

Parameters:

file : file or string

File or filename to which the data is saved. If the filename does not already have a .npy extension, it is added.

arr : array_like

Array data to be saved.

See also

savez
Save several arrays into a .npz compressed archive

savetxt, load

Notes

For a description of the .npy format, see format.

Examples

>>> from tempfile import TemporaryFile
>>> outfile = TemporaryFile()
>>> x = np.arange(10)
>>> np.save(outfile, x)
>>> outfile.seek(0) # only necessary in this example (with tempfile)
>>> np.load(outfile)
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

Previous topic

numpy.load

Next topic

numpy.savez

This Page