python - slicing arrays in numpy/scipy -


i have array like:

a = array([[1,2,3],[3,4,5],[4,5,6]]) 

what's efficient way slice out 1x2 array out of has first 2 columns of "a"?

i.e.,

array([[2,3],[4,5],[5,6]]) in case. 

thanks.

two dimensional numpy arrays indexed using a[i,j] (not a[i][j]), can use same slicing notation numpy arrays , matrices can ordinary matrices in python (just put them in single []):

 >>> numpy import array >>> = array([[1,2,3],[3,4,5],[4,5,6]]) >>> a[:,1:] array([[2, 3],        [4, 5],        [5, 6]]) 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -