dot product (1) 썸네일형 리스트형 Data Analysis / NumPy / ndarray(2) # reshape()와 resize() import numpy as np # ndarray의 shape 조절 함수 # reshape() : 원하는 형태(shape)로 ndarray의 shape를 조절 # ravel() : 1차원 vector(1차원 ndarray)로 shape를 변형 # 정수형태의 난수를 이용해서 (3,4) shape을 가지는 ndarray 생성 np.random.seed(10) arr = np.random.randint(0, 10, (3,4)) # result = arr.resize(2,6) # error : view가 생성되는 것이 아니라 원본이 변함 # reshape() 함수는 요소의 개수가 맞지 않으면 reshape가 되지 않음.. 이전 1 다음