I have a numpy list which I initiate by (my_array= and has a shape of (0,)) then I append the wm and hm elements to it like so(r is a cascade with the format of-[[300 240 22 22]]):
my_array= for (x, y, w, h) in r: wm=int(x+ (w/2.)) hm=int(y+ (h/2.)) my_array.append([numpy.float32(wm), numpy.float32(hm)]) return numpy.array(my_array)
That code produces: wm element the hm element [[270.01 303.43] [310.17 306.37]] # second to last row [[269.82 303.38] [310.99 306.86]] # the last row the shape of the returned array is (2,2) and is dtype:float32
Now the problem is that when I tried to append the 303.43 it theoretically would be [-2] but it indexes 303.38. which is fine but I also need to index 303.43 as well.
What I found was that the first  indexes either the wm or hm element, then the second  indexes one of the two columns of values inside each element
-for example [-1] indexes the wm element and last row [-1] I want to index the second last row as well and tried [-2] but it didn't work as intended(it indexed the 269.82).
So I tried [-2] but it didn't work due to IndexError: invalid index to scalar variable.
All I want to do is to find the difference between the last and second to last row for the 2 columns in the wm element(so in the example above it would be 269.82-270.1=-0.19 and 303.38-303.43=-0.05). All solutions presented in other questions dont work ([-1],[-1], you can try them yourself to find out) The indexing doesn't work. So is there a way around this problem? Please explain it fully because I am still kind of new to this! Thanks in advance!
Taking the last two blocks of data
Indexing the array (in the idle) fetches(I copied the last two blocks of the array):
[[293.51373 323.4329 ]
[[292.9887 322.23425] [247.24142 314.2921 ]]
On my program, it shows up as (the same array)
--wm element------------------hm element
[[293.51373 323.4329 ][247.77493 316.02783]] I consider this the second to last row
[[292.9887 322.23425][247.24142 314.2921 ]] and I thought this was the last row
This brought forth a lot of confusion for me, but I ignored the minor difference of the way they are displayed until now. Now, the question is how to index the 323.4329 and the 293.51373 numbers, it would be better if they can be indexed separately?