I have an x dimensional matrix in Numpy. For this example, I will use a 2x2 array.
np.array([[2, 2], [3,3]])
How would I alternate adding a row and column of some value so the result would look like:
array([[2, x, 3, x],
[x, x, x, x].
[2, x, 3, x],
[x, x, x, x]])
This answer gives a helpful start by saying to set rows in a correctly-sized destination matrix b
from a matrix a
like so a[::2] = b
but what does the ::2
do in the slicing syntax and how can I make it work on columns?
In short what do the x
y
and z
parameters do in the following: a[x:y:z]
?