简单的Numpy Reshape,相同的操作给出了不同的形状

时间:2017-10-31 09:16:49

标签: python numpy

我有以下代码部分:

print X.shape
print Y.shape
X = X[np.where(X[:, 2] > 0.05)]
Y = Y[np.where(Y[:, 2] > 0.05)]
print X.shape
print Y.shape
print Y

代码的输出是:


(231, 3)
(231, 3)
(55, 3)
(1, 56)
[[-1.98769812 -1.93259862 -2.29080624 -0.83792838 -1.94892429 -1.58289539
  -1.90247292 -1.4556473  -2.19070534 -1.73212961 -1.61395937 -1.14633543
  -1.10683535 -1.02509949 -1.25594622 -1.4080105  -1.63474736 -1.95824227
  -2.17106426 -1.91125435 -2.0718614  -1.89993348 -1.54472541 -0.87961375
  -1.85216151 -2.121226   -1.88453394 -1.29166291 -1.78698561 -2.08983923
  -2.02139995 -0.9349243  -0.90184218 -0.69882058 -1.05909316 -2.15477887
  -1.43069109 -2.03090084 -0.5736147  -1.51153658 -2.22790561 -0.75759474
  -1.76501869 -1.38221479 -1.17738909 -1.64007052 -1.88721801 -1.290115
  -1.76288243 -2.08980588 -1.85872696 -1.79981182 -1.56103353 -1.41155315
  -0.73043509 -1.27204526]]

我原以为更新的Y数组的形状为(56,3)。如何在相同形状的两个numpy阵列上进行相同的操作会产生不同的形状?

0 个答案:

没有答案