亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Python數(shù)據(jù)分析numpy的Nan和Inf使用注意點詳解

 更新時間:2023年08月21日 09:21:00   作者:YiYa_咿呀  
這篇文章主要為大家介紹了Python數(shù)據(jù)分析numpy的Nan和Inf使用注意點,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

numpy中的Nan

Nan:Not a number

np.count_nonzero(arr[type==bool]):判斷數(shù)組內(nèi)FALSE的個數(shù)

np.isnan(arr):返回值為arr值為nan的索引

Nan的注意點

1.兩個nan是不相等的

應用

  • 利用以上的特性,判斷數(shù)組中nan的個數(shù)

  • 將nan轉換為0值

  • nan和inf屬于浮點類型

nan與任何數(shù)進行運算都是nan

numpy常見統(tǒng)計函數(shù)

import numpy as np
t1 = np.arange(12).reshape(3,4).astype(float)
t1[1,2:]=np.nan
print(t1)
for i in range(t1.shape[1]): # 對列進行循環(huán)
    temp_col = t1[:,i] #選中當前的那一列
    nan_col = np.nonzero(t1!=t1)
    if nan_col != 0:
        temp_non_nan_col = temp_col[temp_col==temp_col]
        temp_col[np.isnan(temp_col)]=temp_non_nan_col.mean()
print(t1)

以上就是Python數(shù)據(jù)分析numpy的Nan和Inf使用注意點詳解的詳細內(nèi)容,更多關于Python數(shù)據(jù)分析numpy Nan Inf的資料請關注腳本之家其它相關文章!

相關文章

最新評論