Index and slice of NumPy array in python

1. One-dimensional array index and slice
1. The index of the array starts from 0;
Insert picture description here
2. The index of the array starts from -1 from right to left, and one digit to the left is subtracted by 1.
Insert picture description here
3. The slice is [m, n) (ie, left closed and right open) interval;
Insert picture description here
4. Copy the scalar to the slice, and it will broadcast to the entire area of ​​the slice.
Insert picture description here
2. Two-dimensional array
1.array_name[0]: The element whose first-dimensional subscript (index value) is 0 is an array;
Insert picture description here

2.array_name[m,n]: represents the first dimension subscript m, the second dimension is the element of n (or understood as the element of m+1 row, n+1 column)
Insert picture description here

3.array_name[:n]: select the first n rows (not n-1, because the rows start from 0)
Insert picture description here
4.array_name[m:n,x:y]: select the mth to nth subscripts of the first dimension -1 line, select the area where the second dimension subscripts x to y-1 overlap.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44801116/article/details/110246767