Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

numpy roundup to nearest 5

#To roundup to nearest 5
import numpy as np
def roundup(x):
    return int(np.ceil(x / 5.0)) * 5
Comment

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.])
Comment

PREVIOUS NEXT
Code Example
Python :: abs in python 3 
Python :: adding strings together 
Python :: function with args* example 
Python :: plot multiplr linear regression model python 
Python :: how to multiply in python 
Python :: add favicon in django admin 
Python :: python type annotations list of specific values 
Python :: django jsonresponse 
Python :: counter library python 
Python :: python file save 
Python :: python dictionary with list 
Python :: fastest way to take screenshot python 
Python :: drop dataframe columns 
Python :: rename rows pandas based on condiions 
Python :: count values python 
Python :: long in python 
Python :: text to image python 
Python :: python __repr__ meaning 
Python :: ord() in python 
Python :: how to write manual querry in drf 
Python :: how to add to a list python 
Python :: python given upper triangle construct symmetric matrix 
Python :: Install pygmt in Anaconda prompt 
Python :: log in python 
Python :: how to keep track of your sport running times in python 
Python :: feature importance plot using lasso regression 
Python :: create database python 
Python :: import open3d Illegal instruction (core dumped) 
Python :: An example of how to associate a color to each bar and plot a color bar 
Python :: plotly ylog 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =