成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

Python中如何使用numpy.where()函數(shù)

小編給大家分享一下Python中如何使用numpy.where()函數(shù),希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!

創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比撫州網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式撫州網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋撫州地區(qū)。費(fèi)用合理售后完善,十年實(shí)體公司更值得信賴。

numpy.where(condition [,x,y])函數(shù)返回滿足給定條件的輸入數(shù)組中元素的索引。

參數(shù):condition : When True, yieldx, otherwise yield y.x,y: Values from which to choose. x, y and

condition need to be broadcastable to some shape.

返回:out : [ndarray or tuple of ndarrays] If both x and y are specified, the output array contains elements of x where condition is True, and elements from y elsewhere.

If only condition is given, return the tuple condition.nonzero(), the indices where condition is True.

代碼1:

# Python program explaining       # where() function         import numpy as np       np.where([[True, False], [True, True]],         [[1, 2], [3, 4]], [[5, 6], [7, 8]])

輸出:

array([[1, 6],       [3, 4]])

代碼2:

# Python program explaining       # where() function         import numpy as np       # a is an array of integers.     a = np.array([[1, 2, 3], [4, 5, 6]])       print(a)       print ('Indices of elements <4')       b = np.where(a<4)     print(b)       print("Elements which are <4")     print(a[b])

輸出:

[[1 2 3] [4 5 6]] Indices of elements <4 (array([0, 0, 0], dtype=int64), array([0, 1, 2], dtype=int64)) Elements which are <4 array([1, 2, 3])

看完了這篇文章,相信你對Python中如何使用numpy.where()函數(shù)有了一定的了解,想了解更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

當(dāng)前文章:Python中如何使用numpy.where()函數(shù)
URL分享:http://jinyejixie.com/article12/gggcgc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)搜索引擎優(yōu)化、域名注冊品牌網(wǎng)站制作、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)
天全县| 宁武县| 晴隆县| 永城市| 平罗县| 嘉善县| 阿拉善左旗| 威远县| 崇阳县| 阜阳市| 瓦房店市| 桦南县| 罗山县| 呼伦贝尔市| 宝山区| 阿拉善左旗| 克拉玛依市| 阳曲县| 类乌齐县| 连平县| 沁水县| 京山县| 昭苏县| 新乡县| 习水县| 杭锦后旗| 綦江县| 平乡县| 安远县| 札达县| 类乌齐县| 海兴县| 隆尧县| 太仓市| 万安县| 溧阳市| 徐汇区| 静乐县| 临漳县| 吉隆县| 临高县|