原博客链接:https://blog.csdn.net/tz_zs/article/details/80775256 np.around: 四舍五入取整 n = np.array([-0.746, 4.6, 9.4, 7.447, 10.455, 11.555]) around1 = np.around(n) print(around1) # [ -1. 5. 9. 7. 10. 12.] np.floor: 向下取整 n = np.array([-1.7, -2.5, -0.2, 0.6, 1.2, 2.7, 11]) floor = np.floor(n) print(floor) # [ -2. -3. -1. 0. 1. 2. 11.] np.ceil: 向上取整 n = np.array([-1.7, -2.5, -0.2, 0.6, 1.2, 2.7, 11]) ceil = np.ceil(n) print(ceil) # [ -1. -2. -0. 1. 2. 3. 11.] np.where: 相当于三元运算符, data = [[ 0.93122679 0.82384876 0.28730977] [ 0.43006042 0.73168913 0.02775572]] result = np.where(data > 0.5, data, 0) print(result) ''' [[ 0.93122679 0.82384876 0. ] [ 0. 0.73168913 0. ]] '''
转载于:https://www.cnblogs.com/kongweisi/p/10661140.html