numpy round to nearest 5

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

showing results for - "numpy round to nearest 5"
Josefina
13 Sep 2019
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