網站首頁 編程語言 正文
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-11-18 Redux模塊化拆分reducer函數流程介紹_React
- 2022-12-15 C++?Boost?MPI接口詳細講解_C 語言
- 2022-07-03 詳解Flutter中Dart集合使用教程_Android
- 2022-03-28 C語言基于EasyX庫實現有顏色彈跳小球_C 語言
- 2022-05-13 windwos11 小愛音箱鏈接上但是沒有聲音
- 2022-07-24 用來將對象持久化的python?pickle模塊_python
- 2022-08-13 uni-app發送請求封裝
- 2022-06-22 C語言關于include順序不同導致編譯結果不同的問題_C 語言
- 最近更新
-
- 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同步修改后的遠程分支