X[:, 1]与X[:,[1]]的区别
import numpy as np
X = np.array([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]])
print(X.shape)
print(X[:, 1])
print(X[:,[1]])
输出:
(10, 2)
[ 1 3 5 7 9 11 13 15 17 19]
[[ 1]
[ 3]
[ 5]
[ 7]
[ 9]
[11]
[13]
[15]
[17]
[19]]
多了一个中括号的效果