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
#2
Ok I solved my problem.

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Metasploit Graph and Append Array Difficulties Tuurbo46 37 756 May-21-2026, 09:31 AM
Last Post: Dustbunny
  possible ctypes and numpy conflict? herbal_rage 1 4,659 Mar-13-2026, 06:54 AM
Last Post: JoelMendoza
Big Grin [solved] how to associate value in an array? paul18fr 9 3,778 Aug-26-2025, 05:44 AM
Last Post: paul18fr
  Numpy, array(2d,bool), flipping regions. MvGulik 2 1,632 Oct-27-2024, 11:06 AM
Last Post: MvGulik
  JSON File - extract only the data in a nested array for CSV file shwfgd 2 2,250 Aug-26-2024, 10:14 PM
Last Post: shwfgd
Shocked Difficulty understanding .moveaxis in Numpy leea2024 2 1,781 Aug-10-2024, 06:07 AM
Last Post: leea2024
  ValueError: could not broadcast input array from shape makingwithheld 1 5,657 Jul-06-2024, 03:02 PM
Last Post: paul18fr
  python code to calculate mean of an array of numbers using numpy viren 3 2,125 May-29-2024, 04:49 PM
Last Post: Gribouillis
  Writing a cycle to find the nearest point from the array Tysrusko 0 1,319 May-10-2024, 11:49 AM
Last Post: Tysrusko
  Elegant way to apply each element of an array to a dataframe? sawtooth500 7 4,880 Mar-29-2024, 05:51 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