I have a numpy array A = np.array([1,2,3]). I want to add 1 to each element of this array, and return an array with each addition, separately:
My desired output would be:
list1 = [[2,2,3][1,3,3][1,2,4]]
I have tried the np.ufunc method to add my arrays, and using a normal list but both methods add the arrays/lists cumulatively:
In[1]: list1 = []
A = np.array([1,2,3])
for i in range(len(A)):
np.add.at(A, [i,], 1)
list1.append(A)
print(list1)
Out[1]: [array([2, 2, 3])]
[array([2, 3, 3]), array([2, 3, 3])]
[array([2, 3, 4]), array([2, 3, 4]), array([2, 3, 4])]
This seems like something that needs to be done outside the for loop, but I'm not sure what.
Where am I going wrong?
Adirectly instead of appending it to a list and printing the list?list1, showed something invalid, now say "in a new list". Can you make up your mind?