原博客链接: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. ]] '''

相关文章:

  • 2022-12-23
  • 2021-08-06
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2022-01-05
  • 2022-12-23
猜你喜欢
  • 2021-06-06
  • 2021-07-06
  • 2021-11-15
  • 2021-07-01
  • 2021-09-30
  • 2021-10-19
  • 2021-12-06
相关资源
相似解决方案