Answers for "numpy round to nearest 5"

0

numpy round to nearest 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.])
Posted by: Guest on August-23-2021

Code answers related to "numpy round to nearest 5"

Python Answers by Framework

Browse Popular Code Answers by Language