1. 程式人生 > >numpy入門——建立二維陣列

numpy入門——建立二維陣列

建立二維陣列

import numpy as np

# 當資料中出現一個字串的時候就會自動將所有元素轉換成字串型別
np1 = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 'True']])

print(np1)

print(np1.shape)

print—>:
[[‘1’ ‘2’ ‘3’ ‘4’ ‘5’ ‘6’ ‘7’ ‘8’ ‘9’]
[‘1’ ‘2’ ‘3’ ‘4’ ‘5’ ‘6’ ‘7’ ‘8’ ‘9’]
[‘1’ ‘2’ ‘3’ ‘4’ ‘5’ ‘6’ ‘7’ ‘8’ ‘True’]]
(3, 9)