Python中文
首页
教程
问答
标签
搜索
登录
注册
在numpy数组中查找最大值及其索引
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我有一个数组,比如:</p> <pre><code>[ [0.0], [0.0020777732133865356], [0.0013433878775686026], [0.00021494206157512963], [8.955918747233227e-05], [0.0], [0.0], [1.7911837858264334e-05], [0.0], [1.7911837858264334e-05], [0.0], [0.0], [0.0], [0.0007702090078964829], [0.02625875361263752], [0.13904960453510284], [0.30124127864837646], [0.30514606833457947], [0.4224506914615631], [0.45712801814079285], [0.5807734131813049], [0.5874545574188232], [0.695248007774353], [0.18126779794692993], [0.11689265072345734], [0.07207723706960678], [0.06512743979692459], [0.06016586348414421], [0.04363323748111725], [0.030235182493925095], [0.03095165640115738], [0.028963441029191017], [0.03578785061836243], [0.029267942532896996]] </code></pre> <p>我想找到最大值及其索引。 我已经找过了,但没有一个符合我的问题。 有什么解决办法吗? 谢谢。</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>如果可以有多个最大值:</p> <pre><code>In [16]: arr = np.array([1,4,3,2,5,6,3,5,7,4,7,1,4,7,3]) In [17]: np.max(arr) Out[17]: 7 In [18]: np.where(arr == np.max(arr)) Out[18]: (array([ 8, 10, 13]),) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python中两个字典的交集
6 回答
python中两个字符串上的异或操作数?
5 回答
Python中两个字符串中的类似句子
3 回答
Python中两个字符串之间的Hamming距离
5 回答
python中两个字符串之间的匹配模式
2 回答
python中两个字符串之间的按位或
4 回答
python中两个字符串之间的数据(字节)切片
6 回答
python中两个字符串之间的模式
10 回答
python中两个字符串作为子字符串的区别
5 回答
Python中两个字符串元组的比较
7 回答
Python中两个字符串列表中的公共字符串
6 回答
python中两个字符串的Anagram测试
5 回答
Python中两个字符串的正则匹配
10 回答
python中两个字符串的笛卡尔乘积
3 回答
Python中两个字符串相似性的比较
9 回答
python中两个字符串语义相似度的求法
2 回答
Python中两个字符置换成固定长度的字符串,每个字符的数目相等
8 回答
Python中两个对数方程之间的插值和平滑数据
6 回答
Python中两个对象之间的And/Or运算符
8 回答
python中两个嵌套字典中相似键的和值
7 回答