Replacement for matlabs accumarray in numpy