Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to round an array in python

import numpy as np
x = np.round([1.45, 1.50, 1.55])
print(x)
x = np.round([0.28, .50, .64], decimals=1)
print(x)
x = np.round([.5, 1.5, 2.5, 3.5, 4.5]) # rounds to nearest even value
print(x)

#output
#[ 1.  2.  2.]                                                          
#[ 0.3  0.5  0.6]                                                       
#[ 0.  2.  2.  4.  4.]
Comment

PREVIOUS NEXT
Code Example
Python :: list comprehension python if 
Python :: pandas take first n rows 
Python :: how to fix Crypto.Cipher could not be resolved in python 
Python :: python list divide 
Python :: flask-callable 
Python :: python print variables and string 
Python :: pandas bin columns 
Python :: python remove repeated elements from list 
Python :: get month day year 12 hour time format python 
Python :: pandas drop row from a list of vlaue 
Python :: how to change python version 
Python :: create pdf from bytes python 
Python :: sort a list of array python 
Python :: how to use static files in django 
Python :: logging - multiple log file 
Python :: System.Windows.Forms.DataGridView.CurrentRow.get returned null. c# 
Python :: np one hot encoding 
Python :: str to tuple of float 
Python :: how to import from parent directory 
Python :: python soup 
Python :: how to find the data type in python 
Python :: dict typing python 
Python :: how to get today weekday in python 
Python :: change value in excel using python 
Python :: doc2vec similarity 
Python :: apply lambda function to multiple columns pandas 
Python :: import get object 
Python :: sys.path.append python 
Python :: pandas crosstab 
Python :: Accessing elements from a Python Dictionary 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =