numpy.compress()

numpy.compress

numpy.compress(condition, a, axis=None, out=None) [source]

Return selected slices of an array along given axis.

When working along a given axis, a slice along that axis is returned in output for each index where condition evaluates to True. When working on a 1-D array, compress is equivalent to extract.