Numpy的around, ceil, floor
1.np.around
around函数有三个参数,第一个是一个array,第二个是小数点的保留位数,第三个参数不经常用(我也不会用)
下面重点介绍decimals参数:参数为0,保留到个位,参数为1,保留到小数点后一位,参数为2,保留到小数点后两位,依次类推。参数为-1,保留到10位,参数为-2,保留到百位,依次类推。
import numpy as np
def test() :
a = np.array([0.51, 0.49, 1.21, 12.51])
print(np.around(a), np.around(a, 1), np.around(a, 2), np.around(a, -1), np

最低0.47元/天 解锁文章
805





