Numpy matrix.compress () method, we can select elements from the matrix by passing the parameter as an array that contains the value 0 to not include the element, or 1 to include the element in the matrix. Just pass the boolean array to
matrix.compress () .
Return: Return a compressed array
Example # 1:
In this example, we can see that using the
matrix.compress () method we can compress the matrix.
[[1 3 3 1]]
Example # 2: p>
[[1 3 4 5 8 9] ]