📌  相关文章
📜  numpy 四舍五入到最接近的 5 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:21.462000             🧑  作者: Mango

代码示例2
#To round to nearest 5
import numpy as np
import pandas as pd
df
>>>
0  34.36
1  1571.80
2  12.54

np.around(df.A.values/5, decimals=0)*5
>>> array([35., 1570., 15.])
#OR 
ar = np.array([34.36, 1571.80, 12.54])
np.around(ar/5, decimals=0)*5
>>> array([35., 1570., 15.])