Get cumulative count per 2d array
I have general data, e.g. strings: np.random.seed(343) arr = np.sort(np.random.randint(5, size=(10, 10)), axis=1).astype(str) print (arr) [['0' '1' '1' '2' '2' '3' '3' '4' '4' '4'] ['1' '2' '2' '2' '3' '3' '3' '4' '4' '4'] ['0' '2' '2' '2' '2' '3' '3' '4' '4' '4'] ['0' '1' '2' '2' '3' '3' '3' '4' '4' '4'] ['0' '1' '1' '1' '2' '2' '2' '2' '4' '4'] ['0' '0' '1' '1' '2' '3' '3' '3' '4' '4'] ['0' '0' '2' '2' '2' '2' '2' '2' '3' '4'] ['0' '0' '1' '1' '1' '2' '2' '2' '3' '3'] ['0' '1' '1' '2' '2' '2' '3' '4' '4' '4'] ['0' '1' '1' '2' '2' '2' '2' '2' '4' '4']] I need count with reset if difference