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

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

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

瀏覽:155日期: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久久,三上悠亚国产精品一区二区三区
日韩成人高清| 99视频精品视频高清免费| 亚洲一区二区三区四区五区午夜 | 中文欧美日韩| av不卡在线看| 美女久久一区| 综合色就爱涩涩涩综合婷婷| 久久亚洲风情| 日韩有码av| 日本欧美在线| 国产精品**亚洲精品| 九一成人免费视频| 久久亚洲精品伦理| 一区二区三区午夜视频| 日韩高清欧美激情| 老司机免费视频一区二区三区| 一本一道久久a久久精品蜜桃| 怡红院精品视频在线观看极品| 国产一区白浆| 日本亚洲不卡| 麻豆精品久久久| 91亚洲人成网污www| 99国产精品免费视频观看| 1024精品久久久久久久久| 天堂成人免费av电影一区| 日韩综合一区二区三区| 日韩精品免费视频人成| 精品丝袜久久| 特黄特色欧美大片| 亚洲欧美久久久| 日本精品久久| 精品国产网站| 五月婷婷六月综合| 日韩高清一区| 福利一区二区免费视频 | 蜜桃视频一区二区三区| 久久精品99国产精品日本| 精品福利久久久| 欧美成人综合| 国产精品老牛| 国产精品视频首页| 日本欧美国产| 亚洲欧美日韩在线观看a三区| 91精品国产自产观看在线| 精品三级av| 亚洲精品va| 久久国产欧美日韩精品| 97精品97| 蜜臀久久久久久久| 久久久久观看| 黄色亚洲精品| 国产精品对白| 狠狠爱www人成狠狠爱综合网| 日本免费新一区视频| 国产欧美一区二区三区精品酒店| 中国女人久久久| 国产极品模特精品一二| 国产综合激情| 国产精品久久久久久久久久齐齐 | 一区二区亚洲视频| 国产黄大片在线观看| 日韩在线a电影| 福利精品在线| 国产精品外国| 97精品国产一区二区三区 | 亚洲综合激情在线| av最新在线| 日韩欧美中文字幕电影| 欧洲在线一区| 国产伦理一区| 野花国产精品入口| 精品亚洲成人| 亚洲精品影院在线观看| 播放一区二区| 国产精品777777在线播放 | 亚洲v天堂v手机在线| 中文在线а√在线8| 亚洲精品中文字幕99999| av资源亚洲| 欧美日本二区| 中文在线不卡| 日韩欧美1区| 国产亚洲一区二区三区啪| 欧美不卡视频| 蜜臀久久精品| 国产精品久久久久久久免费软件| 国产精品免费看| 国产福利电影在线播放| 久久精品xxxxx| 免费久久99精品国产| 99精品网站| 麻豆理论在线观看| 国产日韩欧美高清免费| 先锋影音国产一区| 激情欧美丁香| 日韩欧美一区免费| 国产精品18| 国产精品最新| 日韩高清一区在线| 亚洲精选91| 亚洲作爱视频| 精品一区亚洲| 亚洲午夜视频| 久久免费国产| 日韩理论视频| 91欧美在线| 国产精品麻豆久久| 国产精品美女在线观看直播| 亚洲精品动态| 免费成人在线影院| 一区二区精彩视频| 丝袜美腿亚洲一区| 国产亚洲毛片在线| 在线视频亚洲| 99热精品在线观看| 亚洲黄色影院| 国产亚洲毛片在线| 视频一区在线视频| 人人爽香蕉精品| 久久亚洲风情| 综合激情一区| 蜜桃av一区二区三区电影| 亚洲一区日韩| 国产视频一区欧美| 久久xxxx精品视频| 爽好久久久欧美精品| 蜜桃传媒麻豆第一区在线观看| 日韩在线观看一区二区| 中文一区一区三区免费在线观| 首页亚洲欧美制服丝腿| 综合亚洲视频| 免费观看在线综合色| 蜜桃av一区二区在线观看| 亚洲青青久久| 中文精品电影| 日韩不卡在线观看日韩不卡视频 | 国产日产高清欧美一区二区三区| 欧美片第1页综合| 国产高清视频一区二区| 国产中文欧美日韩在线 | 亚洲成a人片| 激情综合网址| 亚洲欧美日韩在线观看a三区| 综合激情婷婷| 国产精品午夜一区二区三区| 麻豆免费精品视频| 久久亚洲人体| 欧美日韩国产v| 午夜精品免费| 日韩欧美中文字幕在线视频| 嫩呦国产一区二区三区av| 成人福利av| 国产精品日韩| 国产剧情一区二区在线观看| 欧美片网站免费| 精品国产午夜| 中文不卡在线| 国产精久久一区二区| 黄色亚洲精品| 超级白嫩亚洲国产第一| 午夜欧美理论片| 欧美综合另类| 伊人久久婷婷| 播放一区二区| 亚洲精品97| 日本麻豆一区二区三区视频| 麻豆精品99| 国产综合亚洲精品一区二| 综合国产精品| 精品视频91| 亚洲免费网址| 国产亚洲精aa在线看| 色在线视频观看| 中文无码日韩欧| 精品国产麻豆| 99在线精品视频在线观看| 国产亚洲第一伦理第一区| 国产激情精品一区二区三区| 精品日韩视频| 亚洲精品极品| 成人小电影网站| 免费在线观看精品| 精品国产三区在线| 99亚洲视频| 精品国产欧美日韩一区二区三区| 午夜av一区| 麻豆精品久久久| 国产农村妇女精品一二区| 国产福利资源一区| 国产视频亚洲| 成人亚洲一区二区| 亚洲97av| 中国字幕a在线看韩国电影| 免费看黄色91| 日韩在线欧美| 青草国产精品| 欧美~级网站不卡| 精品视频在线观看网站| 视频一区视频二区中文字幕| 国产69精品久久|