How to delete columns of a NumPy array in Python

One of the most useful features of a numpy.ndarray is the ability to access entire columns of data. This also makes it easier to delete a whole column. For example, given the array [1, 2, 3], [4, 5, 6], deleting the second column would yield the array [1, 3], [4, 6].

Solution for How to delete columns of a NumPy array in Python : You can use numpy.delete() to delete columns from a numpy.ndarray Call numpy.delete(array, indices, axis) to get the new numpy.ndarray without the selected columns. Pass array as the original array, indices as the index to remove or a list of indices to remove, and axis as the axis to remove from. For the axis parameter, 0 indicates rows and 1 indicates columns.


how-to-delete-columns-of-a-numpy-array-in-python