I have a very quick question about the notation on accessing an array in python.
Is this line:
trainPredictPlot[look_back:len(trainPredict) + look_back, :] = trainPredict
I've seen arrays are being accessed like this x[a:b] but never like this x[a:b,:]
Can someone explain me with detail what this line of code is doing? What does it mean to put colon before the closing bracket? What about the comma?
1 Answer 1
When you use x[a:b], it means that you are taking the elements from position "a" (x[a]) to position "b" (x[b]) of a one dimensional array. For the second case x[a:b,:], it is a two dimensional "a" to position "b" of the first dimension of the array, and all the elements of the second dimension of the array, in other words, from x[a][first element] to x[b][last element].
m[a:b, :]. Note the comma. See docs.scipy.org/doc/numpy/reference/arrays.indexing.html