欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

numpy如何獲取array中數(shù)組元素的索引位置

 更新時(shí)間:2023年01月18日 10:31:42   作者:yuan0061  
這篇文章主要介紹了numpy獲取array中數(shù)組元素的索引位置,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

numpy - 獲取array中數(shù)組元素的索引

<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">閱讀數(shù):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"  rel="external nofollow" >
        <div class="htmledit_views">

1. 函數(shù)原型

argwhere(array):找到非空數(shù)組array在滿足某些條件下的索引,返回索引數(shù)組。

2. 應(yīng)用

2.1 一維數(shù)組

返回一個(gè)一維數(shù)組,代表當(dāng)前滿足條件的元素出現(xiàn)的位置。

# -*- 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 二維數(shù)組

返回二維數(shù)組,代表當(dāng)前滿足條件的元素出現(xiàn)的位置。

# -*- 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)

參考文獻(xiàn)

http://blog.csdn.net/vernice/article/details/50990919

            </div>
        </article>

    <div class="article-bar-bottom">
            <div class="article-copyright">
        版權(quán)聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。          https://blog.csdn.net/ZK_J1994/article/details/76707734     </div>
                    <div class="tags-box artic-tag-box">
        <span class="label">文章標(biāo)簽:</span>
                    <a class="tag-link"  rel="external nofollow"  target="_blank">Python                     </a><a class="tag-link"  rel="external nofollow"  target="_blank">numpy                       </a>
    </div>
                    <div class="tags-box">
        <span class="label">個(gè)人分類:</span>
                    <a class="tag-link"  rel="external nofollow"  target="_blank">Python                       </a>
    </div>
                    <div class="tags-box">
        <span class="label">所屬專欄:</span>
                    <a class="tag-link"  rel="external nofollow"  target="_blank">Python</a>

    </div>
        </div>

<!-- !empty($pre_next_article[0]) -->
    </div>

到此這篇關(guān)于numpy獲取array中數(shù)組元素的索引位置的文章就介紹到這了,更多相關(guān)numpy array數(shù)組索引內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python在游戲中的熱更新實(shí)現(xiàn)

    Python在游戲中的熱更新實(shí)現(xiàn)

    本文主要介紹了Python在游戲中的熱更新實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-10-10
  • python中telnetlib模塊的使用方式

    python中telnetlib模塊的使用方式

    這篇文章主要介紹了python中telnetlib模塊的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-11-11
  • python操作MongoDB基礎(chǔ)知識(shí)

    python操作MongoDB基礎(chǔ)知識(shí)

    MongoDB支持好多語言,今天我們就寫一寫python操作MongoDB的知識(shí),從安裝MongoDB到操作MongoDB全都有了。
    2013-11-11
  • 簡單學(xué)習(xí)Python time模塊

    簡單學(xué)習(xí)Python time模塊

    這篇文章主要和大家一起簡單學(xué)習(xí)一下Python time模塊,Python time模塊提供了一些用于管理時(shí)間和日期的C庫函數(shù),對(duì)time模塊感興趣的小伙伴們可以參考一下
    2016-04-04
  • python中plot實(shí)現(xiàn)即時(shí)數(shù)據(jù)動(dòng)態(tài)顯示方法

    python中plot實(shí)現(xiàn)即時(shí)數(shù)據(jù)動(dòng)態(tài)顯示方法

    這篇文章主要為大家詳細(xì)介紹了python中plot實(shí)現(xiàn)即時(shí)數(shù)據(jù)動(dòng)態(tài)顯示方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-06-06
  • python 多線程死鎖問題的解決方案

    python 多線程死鎖問題的解決方案

    這篇文章主要介紹了python 多線程死鎖問題的解決方案,幫助大家更好的理解和學(xué)習(xí)python 鎖,感興趣的朋友可以了解下
    2020-08-08
  • python使用Pyinstaller如何打包整個(gè)項(xiàng)目

    python使用Pyinstaller如何打包整個(gè)項(xiàng)目

    這篇文章主要介紹了python使用Pyinstaller如何打包整個(gè)項(xiàng)目,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • Python類屬性的延遲計(jì)算

    Python類屬性的延遲計(jì)算

    這篇文章主要為大家詳細(xì)介紹了Python類屬性的延遲計(jì)算,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • python heic后綴圖片文件轉(zhuǎn)換成jpg格式的操作

    python heic后綴圖片文件轉(zhuǎn)換成jpg格式的操作

    這篇文章主要介紹了python heic后綴圖片文件轉(zhuǎn)換成jpg格式的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2021-03-03
  • python process模塊的使用簡介

    python process模塊的使用簡介

    在python中大部分情況需要使用多進(jìn)程,python提供了multiprocessing模塊。multiprocessing模塊的功能眾多:支持子進(jìn)程、通信和共享數(shù)據(jù)、執(zhí)行不同形式的同步,提供了Process、Queue、Pipe、Lock等組件。本文將著重講解process模塊的使用
    2021-05-05

最新評(píng)論