1 回答

TA貢獻(xiàn)1895條經(jīng)驗(yàn) 獲得超7個(gè)贊
當(dāng)您使用兩對(duì)括號(hào)尋址數(shù)據(jù)時(shí),您將執(zhí)行兩個(gè)操作,第一個(gè)括號(hào)從數(shù)據(jù)中選擇一個(gè)新數(shù)組,第二個(gè)括號(hào)尋址新數(shù)組。
In [71]: np.random.seed(2020)
...: fridge = np.random.randint(11, size=(30, 5))
...: tasty = fridge_items[:,4] > 7
...: tastyfridge = fridge[tasty,:]
In [72]: tastyfridge[:2,:], fridge[tasty][:2,:]
Out[72]:
(array([[ 8, 10, 9, 3, 7],
[ 4, 7, 1, 4, 9]]),
array([[ 8, 10, 9, 3, 7],
[ 4, 7, 1, 4, 9]]))
In [73]:
添加回答
舉報(bào)