Let\'s say i have a 2d boolean numpy array like this:
import numpy as np a = np.array([ [0,0,0,0,0,0], [0,1,0,1,0,0], [0,1,1,0,0,0], [0,0,0,0
a = np.transpose(a[np.sum(a,1) != 0]) a = np.transpose(a[np.sum(a,1) != 0])
It's not the quickest but it's alright.