Numpy provides two identical methods to do this. Either use

np.round(data, 2)

or

np.around(data, 2)

as they are equivalent.

See the documentation for more information.


Examples:

>>> import numpy as np
>>> a = np.array([0.015, 0.235, 0.112])
>>> np.round(a, 2)
array([0.02, 0.24, 0.11])
>>> np.around(a, 2)
array([0.02, 0.24, 0.11])
>>> np.round(a, 1)
array([0. , 0.2, 0.1])
Answer from Joe Iddon on Stack Overflow
🌐
GitHub
github.com › balapriyac › data-science-tutorials › blob › main › useful-python-scripts-eda › data_profiler.py
data-science-tutorials/useful-python-scripts-eda/data_profiler.py at main · balapriyac/data-science-tutorials
import numpy as np · from typing import Dict, List, Any, Optional · from dataclasses import dataclass · import warnings · warnings.filterwarnings('ignore') · @dataclass · class ColumnProfile: name: str · dtype: str · non_null_count: int ·
Author   balapriyac
🌐
Server Academy
serveracademy.com › blog › python-round-function-tutorial
Python Round() Function Tutorial - Server Academy
Python’s round() function makes it easy to round numbers to a specified number of decimal places or the nearest integer. Whether you need to round up, round down, or round to a specific decimal point, Python has you covered with its versatile round() function.
🌐
Codecademy
codecademy.com › docs › python:numpy › math methods › .round()
Python:NumPy | Math Methods | .round() | Codecademy
June 18, 2024 - Rounds a number or an array of numbers to a specified number of decimal places.
🌐
Medium
medium.com › @heyamit10 › how-to-round-numbers-to-integers-in-numpy-c43b43970c4c
How to Round Numbers to Integers in NumPy? | by Hey Amit | Medium
March 6, 2025 - If a number is exactly halfway between two integers (like 4.5), NumPy rounds it to the nearest even number. So 4.5 becomes 4 because 4 is even. Similarly, 5.5 would round to 6 because 6 is even. Why does this matter? It helps reduce bias when you’re rounding a lot of numbers, especially in large datasets. ✅ How Can I Round Down or Round Up Instead of Standard Rounding?
Find elsewhere
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
3 weeks ago - The behavior of round() for floats can be surprising: for example, round(2.675, 2) gives 2.67 instead of the expected 2.68. This is not a bug: it’s a result of the fact that most decimal fractions can’t be represented exactly as a float.
🌐
TutorialsPoint
tutorialspoint.com › numpy › numpy_round_function.htm
Numpy round() Function
It provides a convenient way to ... The function rounds values according to the standard rounding rules: values equal to or greater than 0.5 are rounded up, while values less than 0.5 are rounded down....
🌐
Kodeclik
kodeclik.com › numpy-round-python
numpy.round() in Python
October 16, 2024 - import numpy as np temperatures = np.array([65.812,70.354,72.311,75.517,82.325]) print(temperatures) ... Note that 65.812 has been rounded (up) to 66 and 70.354 has been rounded (down) to 70. By default numpy.round() rounds to zero decimal places.
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: Round array elements (np.round, np.around, np.rint)
January 15, 2024 - You can define a custom function for standard rounding (rounding half up) instead of rounding half to even, as done by np.round() as follows. After adjusting the number to the desired decimal place, 0.5 is added. Then, np.floor() is applied to truncate the decimal places, effectively rounding down towards negative infinity. Finally, the number is readjusted to its original decimal place. NumPy: Round up/down array elements (np.floor, np.trunc, np.ceil)
🌐
ProjectPro
projectpro.io › recipes › round-away-from-zero-float-array
How to round a NumPy array to nearest integer in Python?- ProjectPro
October 13, 2023 - In this example, numpy.ceil() is used to round up the elements of the array to the nearest integer greater than or equal to each element.
🌐
AskPython
askpython.com › home › numpy round_ – round an array to the given number of decimals.
Numpy round_ - Round an array to the given number of decimals. - AskPython
January 9, 2023 - ... Specifying the decimals (int the parameter decimals)allows us to manage the precision we want after rounding. ... In this article, we learned the NumPy round_ function and how to utilize it to round off elements in an array to a specific decimal.
🌐
Kaggle
kaggle.com › code › colinmorris › functions-and-getting-help
Functions and Getting Help
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
What are some efficient functions to round off numbers in an array? - Python - Data Science Dojo Discussions
November 7, 2022 - I recently discovered a method in NumPy for rounding off all elements of an array to the nearest integer using NumPy’s np.round() function. I’m curious to know if there are any other substitute and efficient methods fo…
🌐
IncludeHelp
includehelp.com › python › how-to-round-a-numpy-array.aspx
Python - How to round a numpy array?
Numpy provides a method to do this. We will use numpy.ndarray.round() method for this purpose. This method returns an array with each element rounded to the given number of decimals.
🌐
Replit
replit.com › home › discover › how to round up in python
How to round up in Python
February 5, 2026 - The final negation flips the sign back, effectively rounding the original division up to the next whole number. It’s a concise way to get a ceiling result without importing the math module. While the standard methods are great for everyday tasks, you'll need more specialized tools for handling large datasets, dynamic precision, or financial calculations. import numpy as np numbers = np.array([1.1, 2.5, 3.9, 4.0]) rounded_up = np.ceil(numbers) print(rounded_up)--OUTPUT--[2.