title: Numpy - create a summary df from array
body: <p>I have a 2d array of 20,10, values ranging from 0 to 12 (created from a dataframe).</p>
  <pre><code>arr = np.random.choice(np.arange(0, 13), size=(20,10))
  array([[0,  9,  9,  7,  6,  2,  6,  4,  4,  3],
         [0,  2,  1,  7,  1,  0,  2,  6,  6,  2],
         [7,  3,  9,  8,  9,  7,  1, 10,  4,  2],
         [0,  7,  0,  1,  4,  5,  8,  4,  2,  2],
         [5,  2, 12,  3, 12,  2,  7, 12,  4, 12],
         [0, 11,  0, 10,  7,  4, 12, 11, 11,  4],
         [0,  9,  9,  8,  5, 11,  7,  6, 10,  7],
         [0,  9,  0, 10, 11,  1,  5, 10,  8, 10],
         [3, 11,  4,  7,  7,  8, 10, 11,  5, 12],
         [0,  5,  0,  8,  1,  5,  1, 11,  9,  1],
         [0,  8,  6, 12, 11,  1,  4, 11,  4,  1],
         [2, 10,  5,  5,  7,  9, 11,  6, 12, 10],
         [9,  8, 11,  4, 10,  1, 10, 12,  0,  3],
         [0,  7, 10,  8,  2, 10,  5,  7,  9,  6],
         [0,  9,  6,  9,  1, 12,  4,  1,  8,  2],
         [8, 12, 10, 12,  8,  2,  3,  0, 11,  4],
         [6,  7, 11, 12,  8,  7,  1,  9,  9,  8],
         [0,  4,  0,  8,  9,  7,  1,  1,  3,  5],
         [0,  8,  1, 11,  2, 12,  6, 11, 12, 10],
         [0,  7,  3,  8,  3,  3,  7,  1,  9,  9]])
  </code></pre>
  <p>Desired output is a dataframe with rows and columns going from 0 to 12. And the cell values should be the count of number of consecutive times a value changes from one value to another in all rows of the array.</p>
  <pre><code>    0   1   2   3   4   5   6   7   8   9   10  11  12
  0   25  20  30                                      
  1                                                   
  2                                                   
  3                                                   
  4   2   2   5           4                           
  5                                                   
  6                                                   
  7                                                   
  8                                                   
  9                                                   
  10                                                  
  11                                                  
  12                                                  
  </code></pre>
  <p>(Not true output)</p>
  <p>For example, in this array, 0 to 9 change occurs 4 times. And 10 to 12 change occurs 2 times:
  <a href="https://i.stack.imgur.com/LDVSU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LDVSU.png" alt="enter image description here" /></a></p>