如何在numpy中使用逗号和括号表示法来获得相同的结果?

2024-05-16 23:56:25 发布

您现在位置:Python中文网/ 问答频道 /正文

The general format is arr_2d[row][col] or arr_2d[row,col]. recommended is comma notation for clarity

假设我有一个numpy数组

arr_2d = np.arange(0,9).reshape((3,3))

arr_2d[:,0] # in row form but the data will be of the column.
>> array([0, 3, 6])

那么如何使用括号表示法访问第一列。


Tags: orthenumpyformatforiscolclarity