3.13.3. Shape Manipulation
import numpy as np
a = np.floor(10*np.random.random((3,4)))
print("3행 4열 배열 생성\n", a)
print("a 배열의 shape = ",a.shape)
print("a.ravel 결과값\n",a.ravel()) # returns the array, flattened
print("a.reshape(6,2) 결과값\n",a.reshape(6,2)) # returns the array with a modified shape
print("a.T 결과값\n",a.T) # returns the array, transposed
print("a.T.shape 결과값 = ",a.T.shape)
print("a.shape 결과값 = ",a.shape)3행 4열 배열 생성
[[8. 0. 1. 7.]
[9. 2. 6. 1.]
[9. 9. 3. 5.]]
a 배열의 shape = (3, 4)
a.ravel 결과값
[8. 0. 1. 7. 9. 2. 6. 1. 9. 9. 3. 5.]
a.reshape(6,2) 결과값
[[8. 0.]
[1. 7.]
[9. 2.]
[6. 1.]
[9. 9.]
[3. 5.]]
a.T 결과값
[[8. 9. 9.]
[0. 2. 9.]
[1. 6. 3.]
[7. 1. 5.]]
a.T.shape 결과값 = (4, 3)
a.shape 결과값 = (3, 4)Last updated
Was this helpful?