ndim

property Matrix.ndim

As for numpy.ndarray