網站首頁 編程語言 正文
numpy - 獲取array中數組元素的索引
<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 >
<div class="htmledit_views">
1. 函數原型
argwhere(array):找到非空數組array在滿足某些條件下的索引,返回索引數組。
2. 應用
2.1 一維數組
返回一個一維數組,代表當前滿足條件的元素出現的位置。
# -*- 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)
2. 2 二維數組
返回二維數組,代表當前滿足條件的元素出現的位置。
# -*- 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" target="_blank">Python </a><a class="tag-link" target="_blank">numpy </a>
</div>
<div class="tags-box">
<span class="label">個人分類:</span>
<a class="tag-link" target="_blank">Python </a>
</div>
<div class="tags-box">
<span class="label">所屬專欄:</span>
<a class="tag-link" target="_blank">Python</a>
</div>
</div>
<!-- !empty($pre_next_article[0]) -->
</div>
原文鏈接:https://blog.csdn.net/yuan0061/article/details/80378575
相關推薦
- 2022-05-20 Springboot讀取application配置文件中的自定義配置的幾種方式
- 2022-07-11 Sonatype Nexus搭建Maven私服
- 2022-10-22 Go語言同步等待組sync.WaitGroup結構體對象方法詳解_Golang
- 2022-06-14 Python?torch.fft.rfft()函數用法示例代碼_python
- 2022-05-22 詳解如何創建一個.NET?Core工程_實用技巧
- 2022-06-07 python中字符串String及其常見操作指南(方法、函數)_python
- 2022-05-21 C語言實現銀行管理系統(文件操作)_C 語言
- 2022-09-18 Python?Pandas實現DataFrame合并的圖文教程_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支