Python Forum
Save Numpy Array in Another Numpy Array (not Concatenate!) - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Save Numpy Array in Another Numpy Array (not Concatenate!) (/thread-30798.html)



Save Numpy Array in Another Numpy Array (not Concatenate!) - quest - Nov-06-2020

Hello;
Here is my code
array1 = ([])
for triplet in itertools.product([0, 1], repeat=6):
    a,ap,b,bp,c,cp = triplet[0],triplet[1],triplet[2],triplet[3],triplet[4],triplet[5]
    nlist = [(a,b,c),(a,b,cp),(a,bp,c),(a,bp,cp),(ap,b,c),(ap,b,cp),(ap,bp,c),(ap,bp,cp)] 
    #arr2 = np.array([])
    arr = np.array([])
    for i in range(8):
        for l in range(8):
            if lst[l] == nlist[i]:
                arr = np.append(arr,[1])
                
            else:
                arr = np.append(arr,[0])
    array1=np.append(array1,arr) #Here is the problem. When I want to add my arr array to array1, the result is like concataneta 
    print(arr)
I want to add arr to array1 like that
array1([arr],[arr],[arr]….)
But the code is adding like that ([arr arr arr arr arr])
How can I solve the this problem?


RE: Save Numpy Array in Another Numpy Array (not Concatenate!) - quest - Nov-06-2020

Ok I solved my problem.

I changed my array type of array1 from numpy array to array like this link link
and It worked.