Useful Coding Tricks
Choose a submatrix
We have a square matrix, take:
Y = np.arange(16).reshape(4,4). Numpy has a nice option to take specific row column combination.
numpy.ix_. The example is as follows:
import numpy as np Y = np.arange(16).reshape(4,4) Y[np.ix_([0,3],[0,3])] # this will chose the columns and rows we need.
Leave a comment