numpy roundup to nearest 5

Solutions on MaxInterview for numpy roundup to nearest 5 by the best coders in the world

showing results for - "numpy roundup to nearest 5"
María Fernanda
24 Sep 2018
1#To roundup to nearest 5
2import numpy as np
3def roundup(x):
4    return int(np.ceil(x / 5.0)) * 5
Francesca
13 Jun 2016
1#To round to nearest 5
2import numpy as np
3import pandas as pd
4df
5>>>
60  34.36
71  1571.80
82  12.54
9
10np.around(df.A.values/5, decimals=0)*5
11>>> array([35., 1570., 15.])
12#OR 
13ar = np.array([34.36, 1571.80, 12.54])
14np.around(ar/5, decimals=0)*5
15>>> array([35., 1570., 15.])
16