This is what the at
method of NumPy ufuncs is for:
output = numpy.zeros(size)
numpy.add.at(output, a[a.cond].ix, a[a.cond].val)
More Related Contents:
- Sorting arrays in NumPy by column
- How to access the ith column of a NumPy multidimensional array?
- Python/NumPy first occurrence of subarray
- Concatenating two one-dimensional NumPy arrays
- Numpy matrix to array
- Replacing Numpy elements if condition is met
- How to make a multidimension numpy array with a varying row size?
- How can I add new dimensions to a Numpy array?
- Force NumPy ndarray to take ownership of its memory in Cython
- How to normalize a NumPy array to within a certain range?
- subsampling every nth entry in a numpy array
- How do I create an empty array and then append to it in NumPy?
- Check if two 3D numpy arrays contain overlapping 2D arrays
- Numpy: Creating a complex array from 2 real ones?
- Index 2D numpy array by a 2D array of indices without loops
- Flattening a list of NumPy arrays?
- Element-wise string concatenation in numpy
- Fastest pairwise distance metric in python
- Partition array into N chunks with Numpy
- Numpy Vector (N,1) dimension -> (N,) dimension conversion
- How is numpy’s fancy indexing implemented?
- numpy division with RuntimeWarning: invalid value encountered in double_scalars
- How does the axis parameter from NumPy work?
- numpy – evaluate function on a grid of points
- Creating a numpy array of 3D coordinates from three 1D arrays
- numpy arange: how to make “precise” array of floats?
- Shift rows of a numpy array independently
- Interweaving two NumPy arrays efficiently
- Formatting floats in a numpy array [duplicate]
- How to convert a 3d numpy array to 2d