Slice Border Of 2D NumPy Array By Integer Value
I would like to slice a 2D NumPy array by an integer value, but I cannot find a way to do this properly. I need to slice the 'border' of the matrix by a certain number of rows/colu
Solution 1:
Use
b = a[slice_val:-slice_val, slice_val:-slice_val]
to slice the borders by slice_val.
Solution 2:
arr=np.ones(25).reshape(5,5)
arr
slice_of_array=arr[1:4,1:4]
slice_of_array
Post a Comment for "Slice Border Of 2D NumPy Array By Integer Value"