
다음배열 x를 x2로 변형하기 위해 알맞은 것을 고르시오
x=[0,1,2,3,4,5,6,7,8,9]
x2= [[0,1,,2,3,4],
[5,6,7,8,9]]
: x.reshape((2,5)) # 행렬이 각각 2,5 인 배열로 reshape

import numpy as np
print("array")
array = np.arange(8)
print(array)
print("shape : ", array.shape, "\n")
# Q1. array를 (2,4) 크기로 reshape하여 matrix에 저장한 뒤 matrix와 그의 shape를 출력해보세요.
print("# reshape (2, 4)")
matrix = array.reshape((2,4))
print(matrix)
print("shape : ", matrix.shape)
: 앞에서 배운 퀴즈와 동일하게, reshape() 함수를 이용하여 행렬의 shape에 주의하여 변환한다.

import numpy as np
print("matrix")
matrix = np.array([[0,1,2,3],
[4,5,6,7]])
print(matrix)
print("shape : ", matrix.shape, "\n")
# (아래의 배열 모양을 참고하세요.)
# Q1. matrix 두 개를 세로로 붙이기
'''
[[0 1 2 3]
[4 5 6 7]
[0 1 2 3]
[4 5 6 7]]
'''
m= np.concatenate([matrix, matrix], axis=0)
# Q2. matrix 두 개를 가로로 붙이기
'''
[[0 1 2 3 0 1 2 3]
[4 5 6 7 4 5 6 7]]
'''
n=np.concatenate([matrix, matrix], axis=1)
np.concatenate( [행렬1, 행렬2] , axis=1 ) : 열 방향으로 병합
: axis=0 인 경우에는 행방향으로 병합