Use a boolean mask:
mask = (z[:, 0] == 6)
z[mask, :]
This is much more efficient than np.where
because you can use the boolean mask directly, without having the overhead of converting it to an array of indices first.
One liner:
z[z[:, 0] == 6, :]
More Related Contents:
- What are the differences between numpy arrays and matrices? Which one should I use?
- numpy matrix vector multiplication [duplicate]
- Numpy matrix to array
- how does multiplication differ for NumPy Matrix vs Array classes?
- Convert a 1D array to a 2D array in numpy
- how to perform max/mean pooling on a 2d array using numpy
- Why does numpy.linalg.solve() offer more precise matrix inversions than numpy.linalg.inv()?
- NumPy array/matrix of mixed types
- Convert row vector to column vector in NumPy
- Is there a NumPy function to return the first index of something in an array?
- Understanding NumPy’s einsum
- Intuition and idea behind reshaping 4D array to 2D array in NumPy
- Computing the correlation coefficient between two multi-dimensional arrays
- Removing nan values from an array
- Why is numpy’s einsum faster than numpy’s built in functions?
- How to return 0 with divide by zero
- Reshape an array in NumPy
- Most efficient way to forward-fill NaN values in numpy array
- Why does numpy.zeros takes up little space
- Efficiently Calculating a Euclidean Distance Matrix Using Numpy
- How to split a numpy array in fixed size chunks with and without overlap?
- Parameters to numpy’s fromfunction
- List to array conversion to use ravel() function
- Efficient distance calculation between N points and a reference in numpy/scipy
- Fastest save and load options for a numpy array
- Numpy find indices of groups with same value
- numpy with python: convert 3d array to 2d
- How is numpy’s fancy indexing implemented?
- How can I slice each element of a numpy array of strings?
- Efficient dot products of large memory-mapped arrays