Python Forum
Save Numpy Array in Another Numpy Array (not Concatenate!)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save Numpy Array in Another Numpy Array (not Concatenate!)
#1
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?
Reply


Messages In This Thread
Save Numpy Array in Another Numpy Array (not Concatenate!) - by quest - Nov-06-2020, 10:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python code to calculate mean of an array of numbers using numpy viren 3 303 May-29-2024, 04:49 PM
Last Post: Gribouillis
  Writing a cycle to find the nearest point from the array Tysrusko 0 270 May-10-2024, 11:49 AM
Last Post: Tysrusko
  Elegant way to apply each element of an array to a dataframe? sawtooth500 7 725 Mar-29-2024, 05:51 PM
Last Post: deanhystad
  Concatenate array for 3D plotting armanditod 1 394 Mar-21-2024, 08:08 PM
Last Post: deanhystad
  Convert numpy array to image without loading it into RAM. DreamingInsanity 7 6,270 Feb-08-2024, 09:38 AM
Last Post: paul18fr
  How Write Part of a Binary Array? Assembler 1 495 Jan-14-2024, 11:35 PM
Last Post: Gribouillis
  Loop over an an array of array Chendipeter 1 693 Nov-28-2023, 06:37 PM
Last Post: deanhystad
  How to remove some elements from an array in python? gohanhango 9 1,878 Nov-28-2023, 08:35 AM
Last Post: Gribouillis
  IPython errors for numpy array min/max methods muelaner 1 729 Nov-04-2023, 09:22 PM
Last Post: snippsat
  how to save to multiple locations during save cubangt 1 677 Oct-23-2023, 10:16 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020