Python 官方文档:入门教程 => 点击学习
目录numpy - 获取array中数组元素的索引1. 函数原型2. 应用2.1 一维数组2. 2 二维数组numpy - 获取array中数组元素的索引 <div class
<div class="article-info-box">
<div class="article-bar-top d-flex">
<span class="time">2017年08月05日 10:36:59</span>
<div class="float-right">
<span class="read-count">阅读数:1797</span>
</div>
</div>
</div>
<article>
<div id="article_content" class="article_content clearfix csdn-tracking-statistics" data-pid="blog" data-mod="popu_307" data-dsm="post">
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/CSS/htmledit_views-0a60691e80.css" rel="external nofollow" >
<div class="htmledit_views">
argwhere(array):找到非空数组array在满足某些条件下的索引,返回索引数组。
返回一个一维数组,代表当前满足条件的元素出现的位置。
# -*- coding: utf-8 -*-
import numpy as np
arr = np.random.randint(0,10, (5,))
index = np.argwhere(arr < 5)
# -*- coding: utf-8 -*-
import numpy as np
arr = np.random.randint(0,10, (5,))
index = np.argwhere(arr < 5)
返回二维数组,代表当前满足条件的元素出现的位置。
# -*- coding: utf-8 -*-
import numpy as np
”“”
arr =
9 3 7 0
3 4 2 4
3 6 4 4
index =
0 1
0 3
1 0
1 1
1 2
1 3
2 0
2 2
2 3
”“”
arr = np.random.randint(0,10, (3,4))
index = np.argwhere(arr < 5)
# -*- coding: utf-8 -*-
import numpy as np
"""
arr =
9 3 7 0
3 4 2 4
3 6 4 4
index =
0 1
0 3
1 0
1 1
1 2
1 3
2 0
2 2
2 3
"""
arr = np.random.randint(0,10, (3,4))
index = np.argwhere(arr < 5)
参考文献
Http://blog.csdn.net/vernice/article/details/50990919
</div>
</article>
<div class="article-bar-bottom">
<div class="article-copyright">
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZK_J1994/article/details/76707734 </div>
<div class="tags-box artic-tag-box">
<span class="label">文章标签:</span>
<a class="tag-link" href="http://so.csdn.net/so/search/s.do?q=python&t=blog" rel="external nofollow" target="_blank">Python </a><a class="tag-link" href="http://so.csdn.net/so/search/s.do?q=numpy&t=blog" rel="external nofollow" target="_blank">numpy </a>
</div>
<div class="tags-box">
<span class="label">个人分类:</span>
<a class="tag-link" href="https://blog.csdn.net/zk_j1994/article/cateGory/6550054" rel="external nofollow" target="_blank">Python </a>
</div>
<div class="tags-box">
<span class="label">所属专栏:</span>
<a class="tag-link" href="https://blog.csdn.net/column/details/16129.html" rel="external nofollow" target="_blank">Python</a>
</div>
</div>
<!-- !empty($pre_next_article[0]) -->
</div>
到此这篇关于numpy获取array中数组元素的索引位置的文章就介绍到这了,更多相关numpy array数组索引内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: numpy如何获取array中数组元素的索引位置
本文链接: https://www.lsjlt.com/news/178081.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0