9951 explained code solutions for 126 technologies


python-numpyHow to load multiple arrays from npz file


This will work if multiple arrays were saved to npz file using savez method.

import numpy as np

z = np.load('/tmp/numpies.npz')

print(z.files)
print(z['arr_0'])ctrl + c
import numpy as np

load Numpy module for Python

.load

loads Numpy array from specified file

/tmp/numpies.npz

path to file to load from (npz means we're loading multiple arrays, that were previously saved)

z['arr_0']

access first loaded array

z.files

access all loaded arrays