日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

numpy数组如何将数组中的元素批量保留小数(或精确到指定位)?np.around()函数(与np.round()函数等价?)

發(fā)布時間:2025/3/20 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 numpy数组如何将数组中的元素批量保留小数(或精确到指定位)?np.around()函数(与np.round()函数等价?) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

From numpy\core\fromnumeric.py

def around(a, decimals=0, out=None):"""Evenly round to the given number of decimals.平等地舍入到給定的小數(shù)位數(shù)。Parameters----------a : array_likeInput data.decimals : int, optionalNumber of decimal places to round to (default: 0). Ifdecimals is negative, it specifies the number of positions tothe left of the decimal point.要舍入的小數(shù)位數(shù)(默認(rèn)值:0)。 如果 decimals 值為負(fù)數(shù),則指定小數(shù)點左側(cè)的位數(shù)。out : ndarray, optionalAlternative output array in which to place the result. It must havethe same shape as the expected output, but the type of the outputvalues will be cast if necessary. See `doc.ufuncs` (Section"Output arguments") for details.放置結(jié)果的替代輸出數(shù)組。 它必須具有與預(yù)期輸出相同的形狀,但是如有必要,將強制轉(zhuǎn)換輸出值的類型。 有關(guān)詳細(xì)信息,請參見`doc.ufuncs`(“輸出參數(shù)”部分)。Returns-------rounded_array : ndarrayAn array of the same type as `a`, containing the rounded values.Unless `out` was specified, a new array is created. A reference tothe result is returned.The real and imaginary parts of complex numbers are roundedseparately. The result of rounding a float is a float.與“ a”類型相同的數(shù)組,其中包含四舍五入的值。 除非指定了`out`,否則將創(chuàng)建一個新數(shù)組。 返回對結(jié)果的引用。復(fù)數(shù)的實部和虛部分別取整。 將浮點數(shù)舍入的結(jié)果是一個浮點數(shù)。See Also--------ndarray.round : equivalent methodceil, fix, floor, rint, truncNotes-----For values exactly halfway between rounded decimal values, NumPyrounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,-0.5 and 0.5 round to 0.0, etc. Results may also be surprising dueto the inexact representation of decimal fractions in the IEEEfloating point standard [1]_ and errors introduced when scalingby powers of ten.對于恰好介于四舍五入的十進(jìn)制值之間的值,NumPy會四舍五入為最接近的偶數(shù)。 因此,將1.5和2.5四舍五入為2.0,將-0.5和0.5四舍五入為0.0,等等。由于IEEE浮點標(biāo)準(zhǔn)[1] _中小數(shù)部分的不精確表示以及以10的冪進(jìn)行縮放時引入的誤差,結(jié)果也可能令人驚訝。 。References----------.. [1] "Lecture Notes on the Status of IEEE 754", William Kahan,http://www.cs.berkeley.edu/~wkahan/ieee754status/IEEE754.PDF.. [2] "How Futile are Mindless Assessments ofRoundoff in Floating-Point Computation?", William Kahan,http://www.cs.berkeley.edu/~wkahan/Mindless.pdfExamples-------->>> np.around([0.37, 1.64])array([ 0., 2.])>>> np.around([0.37, 1.64], decimals=1)array([ 0.4, 1.6])>>> np.around([.5, 1.5, 2.5, 3.5, 4.5]) # rounds to nearest even value 四舍五入到最接近的偶數(shù)值array([ 0., 2., 2., 4., 4.])>>> np.around([1,2,3,11], decimals=1) # ndarray of ints is returned 返回int的ndarrayarray([ 1, 2, 3, 11])>>> np.around([1,2,3,11], decimals=-1)array([ 0, 0, 0, 10])"""return _wrapfunc(a, 'round', decimals=decimals, out=out)

參考文章1:【numpy】【ndarray】指定每個元素保留小數(shù)點后多少位【around】【round】

參考文章2:numpy數(shù)組中round, around, rint, ceil, floor, modf, trunc, fix

總結(jié)

以上是生活随笔為你收集整理的numpy数组如何将数组中的元素批量保留小数(或精确到指定位)?np.around()函数(与np.round()函数等价?)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲国语| mdyd—856冲田杏梨在线 | 中国xxxx性xxxx产国 | 男人的亚洲天堂 | 九九九精品视频 | 中文天堂资源在线 | 日本久久久网站 | 四虎在线免费 | n0659极腔濑亚美莉在线播放播放 | 精品动漫av| 五月婷婷天堂 | 污视频在线网站 | 亚洲精品综合在线 | 精品人妻一区二区三区潮喷在线 | 五十路中文字幕 | 欧美激情999 | 干欧美 | 中文字幕一区二区av | 九九九国产视频 | 日本大胆裸体做爰视频 | 国产精品久久久久久久天堂 | 每日在线观看av | 中文字幕视频 | 亚洲女优在线播放 | 亚洲最新在线观看 | 日本电影一区二区三区 | 九九九久久久久 | 成人三级影院 | 亚洲国产一区二区在线 | 秋霞福利网 | jizz欧美大片 | 欧美日韩国产成人在线 | 麻豆tv在线观看 | 国产精品美女一区二区三区 | 成人小视频在线播放 | 女人扒开屁股让我添 | 国产免费黄色小视频 | 中文字幕第88页 | 成人午夜视频免费观看 | 中文久久久 | 日本专区在线 | 鲁丝一区二区三区 | 亚洲精品久久久久久宅男 | 黄色在线视频网址 | 人体私拍套图hdxxxx | 精品一区二区三区无码按摩 | 手机成人在线 | 长河落日电视连续剧免费观看01 | 欧美日韩999 | 欧美日韩色片 | 亚洲国产精品视频一区二区 | 奇米色在线 | av在线免费观看不卡 | 亚洲精品乱码久久久久 | 亚洲精品综合精品自拍 | 美女扒开下面让男人捅 | 伊人青青草原 | 九色91popny蝌蚪 | 天天干干干干干 | 蜜臀av性久久久久av蜜臀妖精 | 午夜试看120秒 | 亚洲图色在线 | 国产好片无限资源 | 99精品视频免费看 | 91精品人妻互换一区二区 | 欧美黑人三级 | 另类小说亚洲色图 | 韩国三级hd中文字幕叫床浴室 | 中国美女黄色一级片 | 蜜桃91麻豆精品一二三区 | 天天想你免费观看完整版高清电影 | 亚洲阿v天堂 | 一级片在线免费看 | 免费激情| 91日批 | 日韩在线一区二区 | 色播视频在线播放 | 波多野结衣一区二区三区免费视频 | 久久视频在线观看 | av一区不卡| 亚洲色图40p | 欧美一级免费 | 97精品国产97久久久久久春色 | 九色91在线| 完全免费在线视频 | 免费视频久久久 | 亲切的金子片段 | 精品一区电影 | 色哟哟一区二区三区四区 | 特黄av | 亚洲天堂2016 | 毛片基地免费 | 精品一区二区久久久久久按摩 | 日韩一区二区三区在线播放 | 日韩一区二区三区视频在线观看 | av丁香| 亚洲无码国产精品 | 亚洲高清免费观看 | 欧美国产精品一区 |