[英]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_total
, num_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 i
行j
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.