我正在寻找np.round(234_567, -3)的等价物,它将产生Out[1]: 235000。但是,我只想向下取整。我想要的输出是:Out[1]: 234000。
np.round(234_567, -3)
Out[1]: 235000
Out[1]: 234000
round舍入到最接近的偶数;要向下舍入,请改用floor。但是,由于它没有decimals参数,因此您需要自己做一下:
round
floor
decimals
np.floor(234_567 / 1_000) * 1_000
或等效地
np.floor(234_567 / 10 ** 3) * 10 ** 3