title: How to translate / shift a numpy array?
body: <p>I am not sure what key-word to search for so if it has been already asked please link the response and close this thread.</p>
  
  <p>I am trying to shift the non-zero entries of a numpy array by a fixed direction, for instance, imagine I have a 2d array:</p>
  
  <pre><code>0 1 2 0
  0 3 0 0
  0 0 0 0
  0 0 0 0
  </code></pre>
  
  <p>Shifting it by (1,1) would produce the following array:</p>
  
  <pre><code>0 0 0 0
  0 0 1 2
  0 0 3 0
  0 0 0 0
  </code></pre>
  
  <p>Let's say if the non-zero entries goes out of bound they're simply dropped. How might I do this?</p>
  
  <p>edit: aparently some duplicate from this? <a href="https://stackoverflow.com/questions/30399534/shift-elements-in-a-numpy-array">Shift elements in a numpy array</a>
  I don't really see why are they the same question at all because that one talks about looping the things out of bound around, so it's more of a "rolling" action rather than shifting. Also I liked the solution here, it is very simple and readable.</p>
  
  <p>edit again: fixed some formats</p>