การ Indexing อาร์เรย์ NumPy

Python สำหรับผู้ใช้ MATLAB

Justin Kiggins

Product Manager

การ Indexing ด้วย Range

arr.shape
(100,)
slice = arr[10:15]

slice.shape
(5,)
Python สำหรับผู้ใช้ MATLAB

การ Indexing อาร์เรย์หลายมิติ

image.shape
(1920, 1200)
window = image[100:150,1000:1100]

window.shape
(50,100)
Python สำหรับผู้ใช้ MATLAB

การ Indexing ด้วยอาร์เรย์ Boolean

data.shape
(10000,)
is_valid.dtype
bool
np.sum(is_valid)
8732
valid_data = data[is_valid]
valid_data.shape
(8732,)
Python สำหรับผู้ใช้ MATLAB

มาฝึกกันเถอะ!

Python สำหรับผู้ใช้ MATLAB

Preparing Video For Download...