What is the bincount method of numpy for/what?

Asked

Viewed 82 times

2

I read the documentation but I don’t understand what it does:

print(np.bincount(np.array([0, 1, 1, 1, 2, 3, 7])))

The exit is:

[1 3 1 1 0 0 0 1]

1 answer

4

This method counts the occurrence of each method in the array.

o número 0 aparece 1 vez 
O número 1 aparece 3 vezes 
O número 2 aparece  1 vez 
o número 3 aparece 1 vez 
0
0
0

These zeros are up to reach the last element since the output vector, by default, is from the max length element of array + 1.

o número 7 (último elemento) aparece 1 vez 
  • 1

    you can see some practical utility for bincount method?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.