How to extract a column from a NumPy array in Python

Extracting a column from a numpy.array returns an array consisting of only the extracted column. For example, extracting the second column from the array [[1, 2],[3, 4]] yields a new array [2, 4].

Solution for How to extract a column from a NumPy array in Python : You can use slicing to extract a column from a NumPy array Use the slicing syntax an_array[:,column] with column as the index of the column to extract. The symbol : indicates that every row will be included in the output.


how-to-extract-a-column-from-a-numpy-array-in-python