Home > Article > Backend Development > delete in numpy deletes the entire row and column of the array
This article mainly introduces the delete in numpy to delete the entire row and column of the array. It has a certain reference value. Now I share it with you. Friends in need can refer to it
numpy delete can delete the entire row and column of the array. The following is a brief introduction and example to illustrate the usage of the delete function:
numpy.delete(arr, obj, axis=None)
Parameters:
arr: input array
obj: slice, integer, indicating which sub-array is to be removed
axis: delete the sub-array Axis
axis = 0: Indicates deleting the rows of the array
axis = 1: Indicating deleting the columns of the array
axis = None: Indicates tiling the array as a one-dimensional array Performing index deletion
returns: a new subarray
x = array([[1,2,3], [4,5,6], [7,8,9]])
1. Delete the i-th row and more Row operations
x = numpy.delete(x, i, axis = 0)
Delete multiple row operations:
2. Delete the i-th column or multiple columns
x = numpy.delete(x,i , axis = 1)
Delete multi-column operation:
3.axis = None Operation
The above is the entire content of this article. For more related content, please pay attention to the PHP Chinese website.
Related recommendations:
numpy array splicing, merging examples on rows and columns respectively
The above is the detailed content of delete in numpy deletes the entire row and column of the array. For more information, please follow other related articles on the PHP Chinese website!