您的位置:首页 > 编程语言 > Python开发

ndarray index in numpy

2016-10-15 16:30 288 查看
a = np.zeros((10,20,3), np.int)
a.shape
# (10,20,3)

a[0][0].shape
a[0, 0].shape
# (3,)
# (3,)

a[0][0:5].shape
a[0, 0:5].shape
# (5,3)
# (5,3)

a[0:3][0:5].shape
a[0:3, 0:5].shape
# (3, 20, 3)
# (3, 5, 3)

a[0:1, 0:5].shape
a[0, 0:5].shape
# (1,20,3)
# (20,3)


a[0:3][0:5] may get unexpected result. Use a[0:3, 0:5].
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: