Reference link: numpy.take in Python
It takes a process to grow, but it takes too long
import numpy as np
a = np.arange(12).reshape(3,4)
print(a)
print(a.take([1,2],axis = 1))#axis = 1 means to take according to the column
print(a.take([1],1))
print(a.take([1,2],axis = 0))#axis = 0 means to take according to the line
Output:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
[[ 1 2]
[ 5 6]
[ 9 10]]
[[1]
[5]
[9]]
[[ 4 5 6 7]
[ 8 9 10 11]]
Process finished with exit code 0
Reference address:
ndarray methods and attributes in numpy-Q_Quan-Blog Park https://www.cnblogs.com/qquan/articles/4917434.html