I am approaching for the first time in numpy and I need to understand if there is actually a method to count the occurrences of the elements, as in the pandas group by: This is the origin matrix:
matrix = [[ 0., 143.],
[ 0., 170.],
[ 0., 143.],
[ 1., 269.],
[ 0., 170.],
[ 1., 269.],
[ 0., 155.],
[ 1., 269.]]
Result output: I should do the groupby for the first column, and the number of occurrences is stored in the last column:
matrix = [[0., 143., 2],
[0., 170., 2],
[1., 269., 3],
[0., 155., 1]]