Okay thanks to "Peter Meisrimel" and "Michael Sidorov" for their answers. I myself tried, creating an empty array first, and then inserting the values in the empty array. I also implemented both answers and tested the performance of all (including the concatenation). To see the performance differences better i increased the size of my n, m, roh substantially. This is my code:
import numpy as np
import itertools
import time
rows = np.arange(40)
columns = np.arange(40)
rohs = np.arange(40)
num1 = np.array([1])
num2 = np.array([2])
start1 = time.time()
asd1 = np.empty((64000,5),dtype=np.float32)
iterator = 0
for a in rows:
for s in columns:
for d in rohs:
asd1[iterator] = a,s,d,1,2
iterator += 1
end1 = time.time()
print("time with empty array: "+str(end1-start1))
start2 = time.time()
asd2 = np.array([a for a in itertools.product(rows,columns,rohs,num1,num2)])
end2 = time.time()
print("time with itertools: "+str(end2-start2))
start3 = time.time()
asd3 = np.array([[n,m,roh,1,2] for n in rows for m in columns for roh in rohs])
end3 = time.time()
print("time with normal np array: "+str(end3-start3))
start4 = time.time()
asd4 = np.array([])
for i in rows:
for j in columns:
for k in rohs:
asd4 = np.concatenate((asd4,[i,j,k,1,2]))
end4 = time.time()
print("time with concatenation: "+str(end4-start4))
As i ran this code i got the following Output:
time with empty array: 0.203110933303833
time with itertools: 0.14061522483825684
time with normal np array: 0.15624260902404785
time with concatenation: 49.35244131088257
So concluding, both given answers were substantially faster than the concatenation method, while using an empty array was relatively fast, using itertools proved to be the fastest way approaching this problem, the difference increasing with larger amounts of permutations.