Facebook
From köksal, 3 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 141
  1. import numpy as np
  2.  
  3. A = [[1, 2, 2, 2, 2],
  4.      [1, 0, 1, 5, 2],
  5.      [1, 1, 4, 6, 2],
  6.      [0, 1, 1, 8, 9]]
  7.      
  8. array = np.array(A)
  9.  
  10. unique, counts = np.unique(array, return_counts=True)
  11. result = dict(zip(unique, counts))
  12. print(result)