2
ndarray
을 여러 줄로 한 줄로 자르는 방법은 무엇입니까? 다음 스 니펫에서 마지막 행을 확인하십시오. 이것은 너무 기본적인 것 같지만 놀람을줍니다 ...하지만 왜?ndarray에서 여러 치수 잘라 내기
import numpy as np
# create 4 x 3 array
x = np.random.rand(4, 3)
# create row and column filters
rows = np.array([True, False, True, False])
cols = np.array([True, False, True])
print(x[rows, :].shape == (2, 3)) # True ... OK
print(x[:, cols].shape == (4, 2)) # True ... OK
print(x[rows][:, cols].shape == (2, 2)) # True ... OK
print(x[rows, cols].shape == (2, 2)) # False ... WHY???
자세한 내용은 다음을 참조하십시오. http://docs.scipy.org/doc/numpy/user/basics.indexing.html#boolean-or-mask-index-arrays – ballsatballsdotballs