• 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
  • 相关阅读:
    【坐在马桶上看算法】算法5:解密回文——栈
    【坐在马桶上看算法】算法4:队列——解密QQ号
    【坐在马桶上看算法】小哼买书
    python项目离线环境配置指南
    vis.js绘图库的一个BUG以及源码修正
    Python 访问soap服务
    一些教训
    Django 图片上传、存储与显示
    WAMP的一些配置修改
    Alpha阶段个人总结
  • 原文地址:https://www.cnblogs.com/yinyoupoet/p/13287396.html
Copyright © 2020-2023  润新知