numpy数组中round, around, rint, ceil, floor, modf, trunc, fix

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

方法名定义作用
roundnp.round(a, decimals=0, out=None)将a四舍五入,精度由参数decimals决定,与around等价
aroundnp.around(a, decimals=0, out=None)与round相同
rintrint(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj])将x中各元素四舍五入为整数
ceilceil(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj])将x中各元素取比它大的最小的整数
floorfloor(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj])将x中各元素取比它小的最大的整数
modfmodf(x[, out1, out2], / [, out=(None, None)], *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj])返回值为两个ndarray,分别为x的小数部分和x的整数部分
trunctrunc(x, /, out=None, *, where=True, casting=‘same_kind’, order=‘K’, dtype=None, subok=True[, signature, extobj])返回x中的整数部分
fixnp.fix(x, out=None)返回x中相对于0的最接近的整数,如:2.9->2;-2.9->-2
  • 4
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值