Array တစ်ခုကို ကောင်းကောင်းကိုင်တွယ်ချင်ရင် သူ့ရဲ့ structure ကိုသိဖို့လိုပါတယ်။ ndim, shape, size, dtype ဆိုတဲ့ attributes တွေက array ထဲမှာ dimension ဘယ်နှစ်ခုရှိလဲ၊ row/column ဘယ်လောက်လဲ၊ element ဘယ်နှစ်ခုလဲ၊ data type ဘာလဲဆိုတာ ပြောပြပေးပါတယ်။
import numpy as np
scores = np.array([[80, 75, 90], [88, 92, 85]])
print("Dimensions:", scores.ndim)
print("Shape:", scores.shape)
print("Total items:", scores.size)
print("Data type:", scores.dtype)ဒီ array မှာ row 2 ခု၊ column 3 ခုရှိပါတယ်။ scores.ndim က 2-D array ဖြစ်ကြောင်းပြောပါတယ်။ scores.shape က (2, 3) ဆိုပြီး row/column အရေအတွက်ကိုပြပါတယ်။ size က element စုစုပေါင်း 6 ခုရှိကြောင်းပြပါတယ်။
Dimensions: 2 Shape: (2, 3) Total items: 6 Data type: int64Info
shape ကိုနားလည်တာက NumPy ရဲ့အရေးကြီးဆုံးအခြေခံတွေထဲကတစ်ခုပါ။ Broadcasting, reshaping, matrix multiplication တွေမှာ shape မကိုက်ရင် error တက်လေ့ရှိပါတယ်။