Use np.all
with an axis
argument:
>>> r[np.all(r == 0, axis=1)]
array([[ 0., 0., 0.]])
>>> r[~np.all(r == 0, axis=1)]
array([[-1.41421356, -0.70710678, -0.70710678],
[ 0. , -1.22474487, -1.22474487]])
More Related Contents:
- Using numpy to build an array of all combinations of two arrays
- Difference between numpy.array shape (R, 1) and (R,)
- Understanding NumPy’s einsum
- Intuition and idea behind reshaping 4D array to 2D array in NumPy
- How does numpy.newaxis work and when to use it?
- What is the difference between flatten and ravel functions in numpy?
- Why is numpy’s einsum faster than numpy’s built in functions?
- How to count the occurrence of certain item in an ndarray?
- Concatenate Numpy arrays without copying
- How do I count the occurrence of a certain item in an ndarray?
- Swap slices of Numpy arrays
- Convert a 1D array to a 2D array in numpy
- Subsetting a 2D numpy array
- Selecting Random Windows from Multidimensional Numpy Array Rows
- How to split a numpy array in fixed size chunks with and without overlap?
- How to find the index of a value in 2d array in Python?
- What is the difference between ndarray and array in NumPy?
- Why using an array as an index changes the shape of a multidimensional ndarray?
- 3d Numpy array to 2d
- Vectorized spatial distance in python using numpy
- Axes from plt.subplots() is a “numpy.ndarray” object and has no attribute “plot”
- Python: how to store a numpy multidimensional array in PyTables?
- Why is B = numpy.dot(A,x) so much slower looping through doing B[i,:,:] = numpy.dot(A[i,:,:],x) )?
- Access n-th dimension in python [duplicate]
- How does the axis parameter from NumPy work?
- Indexing numpy array with another numpy array
- How can I turn a flat list into a 2D array in python?
- Get the indices of N highest values in an ndarray
- Mapping a NumPy array in place
- How to convert a 3d numpy array to 2d