【发布时间】:2019-07-19 18:10:29
【问题描述】:
我正在尝试做多个索引。但是,它显示了太多索引的错误。请帮助我,如果您对此有任何疑问或困惑,请在评论框中留下 cmets。
我的结果有 (6561114,) 形状,我想索引整个第一行,例如 ([array([-1., 1., 0., 0., 1.]), array([[43 ., 0., 43., 1., 2.]]), array([-43., 43., 0., 2., 3.]) 然后从 3 列中提取数组的每个值- 像 [-1,43,-43],[1,0,43] 等等。
This is Output:-
array([array([-1., 1., 0., 0., 1.]),
array([[43., 0., 43., 1., 2.]]),
array([-43., 43., 0., 2., 3.]), ...,
array([-1.406830e+01, 3.552240e+01, 2.145410e+01,
9.492236e+06,
9.492237e+06]),
array([[1.421949e+02, 2.145410e+01, 1.636490e+02, 9.492237e+06,
9.492238e+06],
[3.387300e+01, 1.636490e+02, 1.975220e+02, 9.492238e+06,
9.492239e+06]]),
array([-1.9052487e+02, 1.9752200e+02, 6.9971300e+00,
9.4922390e+06,
9.4922400e+06])], dtype=object)
This is what error looks like:-
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-29-537ba6ddfd42> in <module>
----> 1 result1[0,:]
IndexError: too many indices for array
【问题讨论】:
-
抱歉,我的帖子可能存在格式问题。
-
您的数组是一维的,但您要求的是第二维。
-
你能建议怎么做吗?
-
尝试用较小的数组重现错误...看起来您的数组是一维的,但您要求的是第二维。
-
我知道了。感谢您的帮助和时间。
标签: python arrays numpy numpy-ndarray indices