I have a numpy array and want to add a row to it and modify one column. This is my array:
import numpy as np
small_array = np.array ([[[3., 2., 5.],
[3., 2., 2.]],
[[3., 2., 7.],
[3., 2., 5.]]])
Then, firstly I wnat to add a fixed value (e.g. 2.) to last column. I did it this way:
chg = 2.
small_array[:,:,-1] += chg
next thing that I want to do is adding another row to each aubarray. Added row should have the same first and second columns but third column shold be different. This time chg x 2. should be subtracted from the existing value in third column:
big_array = np.array ([[[3., 2., 7.],
[3., 2., 4.],
[3., 2., 0.]], # this row is added
[[3., 2., 9.],
[3., 2., 7.],
[3., 2., 3.]]]) # this row is added
I very much appreciate any help to do it.