numpy delete method

import numpy as np

lines = np.loadtxt(r'./test.txt',delimiter=',',dtype=int)

print(lines)

lines_copy = lines

lines_rest = np.delete(lines,0,0)

The first parameter #: matrix to be processed, the second argument, the location processing, the third parameter, 0 indicates deleted in rows, in columns 1 to delete

# Return value, the remaining elements constituting the matrix after deleting

print('copy')

print(lines_copy)

print ( 'post-delete')

print(lines_rest)

Output

[[ 123 745 735]
[ 555 892 744]
[ 42 1074 753]]
copy
[[ 123 745 735]
[ 555 892 744]
[ 42 1074 753]]
delete后
[[ 555 892 744]
[ 42 1074 753]]

Guess you like

Origin www.cnblogs.com/shuangcao/p/11326505.html