简体   繁体   English

获取从 2 x 1D arrays 构建的 2D 数组元素的访问索引

[英]Get access index of a 2D array element built from 2 x 1D arrays

I have the following prior_total built from prior_fish array and np.arange(5) with num_prior_loop=50我从prior_fish数组和np.arange(5)构建了以下prior_totalnum_prior_loop=50

# Declare prior array
prior_start = 1
prior_end = 5
prior_fish = np.logspace(prior_start,prior_end,num_prior_loop)
# Prior total
prior_total = np.stack([prior_fish.T, np.arange(5)])

How to get access to prior_total[i,j] , I mean i for the i-th element of prior_fish and j for the j-element of np.aranage(5)?如何访问prior_total[i,j] ,我的意思是i代表prior_fish的第i个元素, j代表np.aranage(5)的第j个元素?

I tried: prior_total[i,j] and prior_total([[[0,i],[1,j]]] but this doesn't work.我试过: prior_total[i,j]prior_total([[[0,i],[1,j]]]但这不起作用。

What might be wrong here?这里可能有什么问题?

a = np.logspace(1,5,5)
b = np.arange(5)
c = np.stack([a.T, b])

c[i,j] returns a single element, at col i row j c[i,j]返回一个元素,位于 col ij

c[0,i], c[1,j] returns two elements, the i th element of a and the j th element of b c[0,i], c[1,j]返回两个元素, a的第i个元素和b的第j个元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM