1mat5 = np.array([['a', 'g', 'c'],
2 ['a', 'b', 'c'],
3 ['f', 'c', 'c']])
4val, cnts = np.unique(mat5, return_counts=True)
5dict_unique = {k: v for k, v in zip(val, cnts)}
6""" result: {'a': 2, 'b': 1, 'c': 4, 'f': 1, 'g': 1} """