Trim the leading and trailing zeros from a 1D array.
filt : array_like
Input array.
trim : string, optional
A string with ‘f’ representing trim from front and ‘b’ to trim from back.
Examples
>>> a = np.array((0, 0, 0, 1, 2, 3, 2, 1, 0)) >>> np.trim_zeros(a) array([1, 2, 3, 2, 1])
numpy.resize
numpy.unique