Numpy Croundup до ближайших 5
#To roundup to nearest 5
import numpy as np
def roundup(x):
return int(np.ceil(x / 5.0)) * 5
Intempestive Al Dente
#To roundup to nearest 5
import numpy as np
def roundup(x):
return int(np.ceil(x / 5.0)) * 5
#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.])