I would like to get the same result as Matlab's accumarray function in Python. I know that there are some other discussions which provide solutions to this problem but the case I consider seems to be more difficult.
It corresponds to the situation of this Matlab script which contains the following line:
binned_data = accumarray(bins(all(bins>0,2),:),1/nrows,M(ones(1,ncols)));
I tried to understand the meaning of this computation by reading the official documentation of accumarray but it is not clear for me.
Do you understand the meaning of this line and know how to get the same result with some Python library (numpy, scipy, pandas, ...)?
EDIT: as far as I understand, my question is different from this one. As you can notice, accumarray has 3 input parameters in my case whereas there are only 2 input parameters in the example from the other discussion. Furthermore, no example of usage of accumarray is provided in the other discussion: the reference to this function only appears in the title (only a very restrictive definition of the function is given by the author). In my case, there is a practical example which seems to be more general than the one considered in the other discussion.