Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created Jan 19, 2021
Embed
What would you like to do?
import numpy as np
a1=np.array([[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]])
#Specific index of an element
print (a1[1][3])
#Output: 9
print (a1[1,3])
#Output: 9
#List of index
print (a1[[1,2],[1,4]])
#Output: [ 7 15]
#Slice
print (a1[1:3,2:4])
#Output:
[[ 8 9]
[13 14]]
#Slice with Step
print (a1[1:3,1::2])
#Output:
[[ 7 9]
[12 14]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment