我的问题是关于numpy中的数组切片。以下行为的逻辑是什么?numpy数组切片,为什么有时是二维数组,有时是一维数组
x = arange(25)
x.shape = (5, 5)
# This results in a 2-d array in which rows and columns are excerpted from x
y = x[0:2, 0:2]
# But this results in a 1-d array
y2 = x[0:2, 0]
我本来期望Y2是一个2-d数组,它包含行0和1的值,列0
这是超级方便有像切片'y2'是一维数组,例如,如果你想拉出一个阵列的每一列绘制它或者通过额外的信号处理运行它,等。 – tacaswell