Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python NumPy delete Function Example

# welcome to softhunt.net
# Python Program illustrating
# numpy.delete()

import numpy as np

#Working on 1D
arr = np.arange(12).reshape(3, 4)
print("arr : 
", arr)
print("Shape : ", arr.shape)

# deletion from 2D array
a = np.delete(arr, 1, 0)
'''
		[[ 0 1 2 3]
		[ 4 5 6 7] -> deleted
		[ 8 9 10 11]]
'''
print("
deleteing arr 2 times : 
", a)
print("Shape : ", a.shape)

# deletion from 2D array
a = np.delete(arr, 1, 1)
'''
		[[ 0 1* 2 3]
		[ 4 5* 6 7]
		[ 8 9* 10 11]]
			^
			Deletion
'''
print("
deleteing arr 2 times : 
", a)
print("Shape : ", a.shape)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Python #NumPy #delete #Function #Example
ADD COMMENT
Topic
Name
3+8 =