I have a NumPy array of shape (550000, 10, 5) and a NormalizeData() function that takes in an array of shape (10, 5) and returns a new array with the same dimensions. I need to transform each of the 550000 arrays. I want to try this as quickly as possible because I will be using much larger arrays in the future.
Is it possible to use broadcasting, or should I employ a for loop?
def NormalizeData(ndata):
ndata[:, -1] = (
(ndata[:, -1] - np.min(ndata[:, -1]))
/ (np.max(ndata[:, -1]) - np.min(ndata[:, -1]))
* 255)
ndata[:, :-1] = (
(ndata[:, :-1] - np.min(ndata[:, :-1]))
/ (np.max(ndata[:, :-1]) - np.min(ndata[:, :-1]))
* 255)
ndata = ndata.round()
return ndata.astype("uint8")
newArray = []
for i in data:
NormalizeData(i)
np.stack(newArray, i)