[Python] numpy reshape(-1,1)
📒 reshape함수 배열과 차원을 변형해주는 함수 1️⃣ np.reshape(변경할 배열, 차원) 2️⃣ 배열.reshape(차원) import numpy as np a = [1,2,3,4,5,6,7,8] b = np.reshape(a,(2,4)) c = np.reshape(a,(4,2)) print(b) print('\n') print(c) >>>[[1 2 3 4] [5 6 7 8]] [[1 2] [3 4] [5 6] [7 8]] 📒 reshape에서 -1의 의미 변경된 배열의 ‘-1’ 위치의 차원은 “원래 배열의 길이와 남은 차원으로 부터 추정”이 된다는 뜻 1️⃣ reshape(-1, 정수) : 행의 위치에 -1인 경우 x.reshape(-1,1) >>> array([[ 0], [ 1], [ 2]..