I have a directory with multiple .npy files (numpy arrays), each file has a 2 dimensional array (same width and height). I need to read all files and generate a 3 dimensional array containing all arrays in directory, the result shape should be something like (# of files, width, height).
My code so far:
import os
import numpy
for file in os.listdir(os.getcwd()):
result = numpy.load(file) #Obviously this doen't work
But I just simply don't know how to generate the result array. Should I first create a zeros array and then fill it? Can I make this on the fly? Can you help me please?
np.dstack(arrays)