プログラム
import numpy as np
def showNpArray(ary):
x = np.array(ary)
print(x) # オブジェクトのダンプ
print(x.shape) # 各次元のサイズ
print(x.ndim) # 何次元の配列か
showNpArray([1, 2, 3])
showNpArray([[1, 2, 3], [2, 4, 6]])
showNpArray([[1, 2, 3], [2, 4, 6], [3, 6, 9]])
実行結果
# showNpArray([1, 2, 3])
[1 2 3]
(3,)
1
# showNpArray([[1, 2, 3], [2, 4, 6]])
[[1 2 3]
[2 4 6]]
(2, 3)
2
# showNpArray([[1, 2, 3], [2, 4, 6], [3, 6, 9]])
[[1 2 3]
[2 4 6]
[3 6 9]]
(3, 3)
2
こちらもおススメ