title: remove empty dimension of numpy array
body: <p>I have a numpy array of shape (X,Y,Z). I want to check each of the Z dimension and delete the non-zero dimension really fast.</p>
  
  <p><strong>Detailed explanation:</strong></p>
  
  <p>I would like to check array[:,:,0] if any entry is non-zero.</p>
  
  <p>If yes, ignore and check array[:,:,1].</p>
  
  <p>Else if No, delete dimension array[:,:,0]</p>