日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

python 的numpy庫中的mean()函數用法介紹

瀏覽:152日期:2022-08-04 14:00:54

1. mean() 函數定義:

numpy.mean(a, axis=None, dtype=None, out=None, keepdims=<class numpy._globals._NoValue at 0x40b6a26c>)[source]Compute the arithmetic mean along the specified axis.

Returns the average of the array elements. The average is taken over the flattened array by default, otherwise over the specified axis. float64intermediate and return values are used for integer inputs.

Parameters:

a : array_like

Array containing numbers whose mean is desired. If a is not an array, a conversion is attempted.

axis : None or int or tuple of ints, optional

Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

New in version 1.7.0.

If this is a tuple of ints, a mean is performed over multiple axes, instead of a single axis or all the axes as before.

dtype : data-type, optional

Type to use in computing the mean. For integer inputs, the default is float64; for floating point inputs, it is the same as the input dtype.

out : ndarray, optional

Alternate output array in which to place the result. The default is None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See doc.ufuncs for details.

keepdims : bool, optional

If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

If the default value is passed, then keepdims will not be passed through to the mean method of sub-classes of ndarray, however any non-default value will be. If the sub-classes sum method does not implement keepdims any exceptions will be raised.

Returns:

m : ndarray, see dtype parameter above

If out=None, returns a new array containing the mean values, otherwise a reference to the output array is returned.

2 mean()函數功能:求取均值

經常操作的參數為axis,以m * n矩陣舉例:

axis 不設置值,對 m*n 個數求均值,返回一個實數

axis = 0:壓縮行,對各列求均值,返回 1* n 矩陣

axis =1 :壓縮列,對各行求均值,返回 m *1 矩陣

舉例:

>>> import numpy as np>>> num1 = np.array([[1,2,3],[2,3,4],[3,4,5],[4,5,6]])>>> now2 = np.mat(num1)>>> now2matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]])>>> np.mean(now2) # 對所有元素求均值3.5>>> np.mean(now2,0) # 壓縮行,對各列求均值matrix([[ 2.5, 3.5, 4.5]])>>> np.mean(now2,1) # 壓縮列,對各行求均值matrix([[ 2.], [ 3.], [ 4.], [ 5.]])

補充拓展:numpy的np.nanmax和np.max區別(坑)

numpy的np.nanmax和np.array([1,2,3,np.nan]).max()的區別(坑)

numpy中numpy.nanmax的官方文檔

原理

在計算dataframe最大值時,最先用到的一定是Series對象的max()方法(),最終結果是4。

s1 = pd.Series([1,2,3,4,np.nan])s1_max = s1.max()

但是筆者由于數據量巨大,列數較多,于是為了加快計算速度,采用numpy進行最大值的計算,但正如以下代碼,最終結果得到的是nan,而非4。發現,采用這種方式計算最大值,nan也會包含進去,并最終結果為nan。

s1 = pd.Series([1,2,3,4,np.nan])s1_max = s1.values.max()>>>nan

通過閱讀numpy的文檔發現,存在np.nanmax的函數,可以將np.nan排除進行最大值的計算,并得到想要的正確結果。

當然不止是max,min 、std、mean 均會存在列中含有np.nan時,s1.values.min /std/mean ()返回nan的情況。

速度區別

速度由快到慢依次:

s1 = pd.Series([1,2,3,4,5,np.nan])#速度由快至慢np.nanmax(s1.values) > np.nanmax(s1) > s1.max()

以上這篇python 的numpy庫中的mean()函數用法介紹就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Python 編程
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
日本精品影院| 国产精品成人3p一区二区三区| 欧美jjzz| 国产精选在线| 日韩精品久久久久久久软件91| 国产日韩亚洲| 亚洲黄色中文字幕| 午夜在线一区二区| 国产在线|日韩| 久久久免费人体| 日本不卡视频在线观看| 欧美中文一区二区| 九九在线精品| 精品日韩视频| 欧美成人久久| 视频一区二区中文字幕| 国产中文一区| 日韩精品影视| 国产不卡一区| 日本91福利区| 国产一区二区精品福利地址| 日本一不卡视频| 蜜臀精品久久久久久蜜臀 | 国产精品普通话对白| 99在线观看免费视频精品观看| 美女毛片一区二区三区四区最新中文字幕亚洲 | 国产欧美一区二区精品久久久| 激情综合网站| 99久久99久久精品国产片果冰| 日韩在线观看一区| 欧美日韩国产在线一区| 亚洲第一精品影视| 偷拍亚洲精品| 精品免费视频| 狠狠干成人综合网| 日韩一区二区三区精品| 国产日韩欧美中文在线| 播放一区二区| 精品久久一区| 四虎精品永久免费| 日欧美一区二区| 综合亚洲视频| 青青伊人久久| 国产麻豆一区| 久久一区精品| 日韩1区在线| 精品久久免费| 偷拍亚洲精品| 黄色亚洲免费| 欧洲精品一区二区三区| 日韩高清成人在线| 日韩精品久久理论片| 91精品国产自产观看在线| 日韩精品永久网址| 精品视频91| 一区在线视频观看| 欧美激情亚洲| 亚洲综合福利| 欧美aa国产视频| 精品久久在线| 国产欧美自拍| 91欧美日韩在线| 首页国产欧美久久| 亚洲综合丁香| 夜夜精品视频| 国产综合精品| 精品久久久网| 日本不卡一二三区黄网| 免费久久99精品国产自在现线| 91成人精品视频| 日韩激情中文字幕| 国产中文字幕一区二区三区| 91精品推荐| 日韩中文字幕区一区有砖一区| 久久午夜影视| 日韩毛片一区| 久久久国产精品网站| 激情丁香综合| 深夜福利一区| 国产午夜久久av| 综合激情网站| 久久久久欧美精品| 欧美日韩一区二区三区不卡视频| 亚洲另类视频| 国产欧美日本| 亚洲影视一区| 日本aⅴ精品一区二区三区 | 玖玖玖国产精品| 久久一区精品| 欧美一区免费| 国产精品v一区二区三区| 国产亚洲欧美日韩在线观看一区二区| 日韩av资源网| 国产videos久久| 天堂网在线观看国产精品| 五月天综合网站| 精品国产精品国产偷麻豆| 久久亚洲色图| yellow在线观看网址| 日韩一区二区三免费高清在线观看 | 国产精品v亚洲精品v日韩精品| 欧美午夜精品一区二区三区电影| 亚洲三区欧美一区国产二区| 偷拍亚洲精品| 亚洲欧美日本视频在线观看| 国产精品magnet| 国产成人精品一区二区三区视频| 亚洲精品极品少妇16p| 日韩一级不卡| 国产精品99精品一区二区三区∴| 欧美日韩黑人| 国产一区二区三区91| 欧美日韩一区二区三区在线电影| 久久伦理在线| 日韩伦理一区| 国产免费播放一区二区| 香蕉成人久久| 日韩欧美中文字幕电影| 97成人在线| 日本a级不卡| 久久不卡日韩美女| 午夜影院一区| 五月天久久网站| 亚洲www免费| 久久久久久一区二区| 欧美有码在线| 国产亚洲一卡2卡3卡4卡新区| 国产亚洲人成a在线v网站| 石原莉奈在线亚洲三区| 黄色亚洲精品| 国产伊人精品| 精品欧美视频| 九九九精品视频| 亚洲少妇一区| 亚洲福利久久| 久久精品国产大片免费观看| 国产一二在线播放| 久久久精品日韩| 国产极品模特精品一二| 色综合视频一区二区三区日韩| 日韩一区二区三区高清在线观看| 日韩视频1区| 国产99精品| 亚洲精品精选| 国产精品中文字幕制服诱惑| 日韩伦理福利| 国产精品一区二区免费福利视频 | 国产欧美日韩影院| 麻豆成全视频免费观看在线看| 正在播放日韩精品| 国产另类在线| se01亚洲视频 | 91精品一区二区三区综合在线爱| 久久精品官网| 午夜久久美女| 欧美综合国产| 日本久久一区| 国产精品18| 国产精品对白久久久久粗| 97在线精品| 视频福利一区| 国产福利一区二区三区在线播放| 丝袜美腿一区二区三区| 免费不卡在线观看| 国产精品久av福利在线观看| 精品久久91| 欧美韩日一区| 亚洲天堂黄色| 日韩精品成人在线观看| 国产精品乱战久久久| 日韩国产综合| 亚洲黄页一区| 中文字幕日韩亚洲| 日本在线观看不卡视频| 国产伦理久久久久久妇女| 国产精品午夜av| 日韩欧美中文字幕电影 | 国产精品啊v在线| 日韩高清一区二区| 日本a级不卡| 亚洲毛片在线| 伊人精品在线| 欧美高清不卡| 日本精品不卡| 日韩1区在线| 国产亚洲高清视频| 亚洲高清av| 视频在线观看一区二区三区| 日本h片久久| 日韩欧美一区二区三区在线观看 | 久久精品超碰| 婷婷激情图片久久| 电影91久久久| 成人精品中文字幕| 日韩另类视频| 福利片在线一区二区| 日韩影院免费视频| 亚洲精选久久| 欧美日韩免费观看一区=区三区| 美腿丝袜亚洲一区|