๋ชฉ์ฐจ
์ ๊ธฐ
import numpy as np
# 1์ฐจ์ ๋ฐฐ์ด์ ์์ฑ๊ฐ
a = np.array([1, 2, 3])
print(a.ndim) # 1
print(a.shape) # (3,)
# 2์ฐจ์ ๋ฐฐ์ด์ ์์ฑ๊ฐ
c = np.array([[1, 2, 3], [4, 5, 6]])
print(c.ndim) # 2
print(c.shape) # (2, 3)
# 3์ฐจ์ ๋ฐฐ์ด์ ์์ฑ๊ฐ
d = np.array([
[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],
[[11, 12, 13, 14], [15, 16, 17, 18], [19, 20, 21, 22]]
])
print(d.ndim) # 3
print(d.shape) # (2, 3, 4)
[์คํ ๊ฒฐ๊ณผ]
1
(3,)
2
(2, 3)
3
(2, 3, 4)
728x90