title: Python - Shift/Delete Elements in a 2-Dimensional Array
body: <p>I need help with shifting and deleting elements in a 2-dimensional array. </p>
  
  <ol>
  <li><p>If the value in a list is negative and their is a list above it with positive values in the same location. It should shift everything down, causing the negative values to disappear. </p></li>
  <li><p>If there isn't any list above it or the corresponding values in the list above are just 0. It will replace the negative values with 0. </p></li>
  </ol>
  
  <p><strong>Note:</strong> The positive values should never disappear, they can only move down when needed. Only the negative values (below -100) disappear. </p>
  
  <p>These examples should explain it better:</p>
  
  <p><strong>Scenario 1:</strong></p>
  
  <p><strong>DATA:</strong> <code>[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 2, 1, 0, 0], [2, 1, 2, 0, 0], [-103, -103, -103, 0, 0]]</code></p>
  
  <p><strong>EXPECT:</strong> <code>[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 2, 1, 0, 0], [2, 1, 2, 0, 0]]</code></p>
  
  <p><strong>Scenario 2:</strong></p>
  
  <p><strong>DATA:</strong> <code>[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 2, -101, -101, -101], [0, 1, 2, 3, 2], [0, 3, 3, 2, 3]]</code></p>
  
  <p><strong>EXPECT:</strong> <code>[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 1, 2, 3, 2], [0, 3, 3, 2, 3]]</code></p>
  
  <p><strong>Scenario 3:</strong> (This is the only one that I got working in my code below.)</p>
  
  <p><strong>DATA:</strong> <code>[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 3, 1, 0, 0], [-102, -102, -102, 0, 0], [3, 1, 3, 0, 0]]</code></p>
  
  <p><strong>EXPECT:</strong> <code>[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 3, 1, 0, 0], [3, 1, 3, 0, 0]]</code></p>
  
  <pre><code>def move(data):
  
      c_count = 4
  
      while c_count &gt;= 0:
  
          count = len(data) - 1
          prev = count - 1
  
          while count &gt; 0 and prev &gt;= 0:
              if data[count][c_count] &lt; -100:
  
                  while prev &gt;= 0 and data[prev][c_count] == 0:
                      prev -= 1
  
                  data[count][c_count] = data[prev][c_count]
                  data[prev][c_count]= 0
  
              count -= 1
              prev -= 1
  
          c_count -= 1
  
      return data
  
  my_data = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 3, 1, 0, 0], [-102, -102, -102, 0, 0], [3, 1, 3, 0, 0]] 
  x = move(my_data) # This is (scenario 3) is the only one that works. 
  print(x)
  </code></pre>
  
  <p>Thanks so much for your help! I have been stuck on this for a while. </p>