zoukankan      html  css  js  c++  java
  • numpy数组中round, around, rint, ceil, floor, modf, trunc, fix

    numpy中对于数组中数字的操作有许多,这里列出常用的一部分,分别是:round, around, rint, ceil, floor, modf, trunc, fix

    方法名 定义 作用
    round np.round(a, decimals=0, out=None) 将a四舍五入,精度由参数decimals决定,与around等价
    around np.around(a, decimals=0, out=None) 与round相同
    rint rint(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj]) 将x中各元素四舍五入为整数
    ceil ceil(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj]) 将x中各元素取比它大的最小的整数
    floor floor(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj]) 将x中各元素取比它小的最大的整数
    modf modf(x[, out1, out2], / [, out=(None, None)], *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj]) 返回值为两个ndarray,分别为x的小数部分和x的整数部分
    trunc trunc(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj]) 返回x中的整数部分
    fix np.fix(x, out=None) 返回x中相对于0的最接近的整数,如:2.9->2;-2.9->-2
  • 相关阅读:
    一切都是对象
    对象入门
    同步计算输入的各个数的总和与平均值
    与时间有关的类Date,DateFormat,Calendar
    获取文件信息
    串行化
    分解
    高速缓存
    压缩
    MyCAT实现MySQL的读写分离
  • 原文地址:https://www.cnblogs.com/yinyoupoet/p/13287396.html
Copyright © 2011-2022 走看看