Is there a MATLAB accumarray equivalent in numpy?

后端 未结 7 1677
时光说笑
时光说笑 2021-01-01 18:06

I\'m looking for a fast solution to MATLAB\'s accumarray in numpy. The accumarray accumulates the elements of an array which belong to the same index. An exampl

相关标签:
7条回答
  • 2021-01-01 19:07

    Use np.bincount with the weights optional argument. In your example you would do:

    np.bincount(accmap, weights=a)
    
    0 讨论(0)
提交回复
热议问题