numpy.around() in Python Last Updated : 12 Jun, 2025 Comments Improve Suggest changes Like Article Like Report The numpy.around() returns a new array with each element rounded to the given number of decimals. It is similar to numpy.round() function and supports various rounding options including rounding to integers or decimal places or even rounding to tens, hundreds and so forth. Python import numpy as np a = np.array([1.2, 2.5, 3.7, 4.4]) res = np.around(a) print(res) Output[1. 2. 4. 4.] np.around(a) rounds each element in the array to the nearest integer because the decimals parameter is not specified and defaults to 0. This means the function rounds all numbers to the nearest integer. Syntaxnumpy.around(a, decimals=0, out=None)Parameters:a (array_like): Input array containing numeric values to be rounded.decimals (optional int, default=0): Number of decimal places to round to 0 rounds to nearest integer, positive values round to specified decimal places, negative values round left of the decimal like tens.out (ndarray, optional): Array to store the result and it must have the same shape as the output.Returns: This function returns a rounded array with the same shape as the input.ExamplesLets see some examples widely used:1. Rounding to 2 decimal places Python import numpy as np a = np.array([1.2345, 2.6789, 3.14159]) res = np.around(a, decimals=2) print(res) Output[1.23 2.68 3.14] np.around(a, decimals=2) rounds each element in the array to 2 decimal places. The decimals=2 parameter tells the function to keep two digits after the decimal point for every number.2. Rounding to the nearest ten (Negative decimals) Python import numpy as np a = np.array([123, 456, 789]) res = np.around(a, decimals=-1) print(res) Output[120 460 790] np.around(a, decimals=-1) rounds each element to the nearest ten. Negative decimals round to the left of the decimal point, so -1 rounds to the nearest multiple of 10.3. Rounding to the nearest hundred Python import numpy as np a = np.array([123, 456, 789]) res = np.around(a, decimals=-2) print(res) Output[100 500 800] np.around(a, decimals=-2) rounds each element to the nearest hundred. Negative decimals round to the left of the decimal point, so -2 rounds to the nearest multiple of 100.4. Using the out parameter to store result in pre-allocated array Python import numpy as np a = np.array([1.567, 2.345, 3.789]) out_array = np.empty_like(a) np.around(a, decimals=1, out=out_array) print(out_array) Output[1.6 2.3 3.8] np.around(...) rounds each element to 1 decimal place and stores the result in out_array, avoiding the creation of a new array. Comment More infoAdvertise with us Next Article numpy.around() in Python mohit gupta_omg :) Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads numpy.floor() in Python The numpy.floor() function returns the largest integer less than or equal to each element in the input array. It effectively rounds numbers down to the nearest whole number. Let's understand with an example:Pythonimport numpy as np a = [0.5, 1.5, 2.5, 3, 4.5, 10.1] res = np.floor(a) print("Floored:" 1 min read numpy.fix() in Python The numpy.fix() is a mathematical function that rounds elements of the array to the nearest integer towards zero. The rounded values are returned as floats. Syntax : numpy.fix(a, b = None) Parameters : a : [array_like] Input array to be floated. b : [ndarray, optional] Output array. Return : The arr 2 min read numpy.argwhere() in Python numpy.argwhere() function is used to find the indices of array elements that are non-zero, grouped by element. Syntax : numpy.argwhere(arr) Parameters : arr : [array_like] Input array. Return : [ndarray] Indices of elements that are non-zero. Indices are grouped by element. Code #1 : Python3 # Pytho 1 min read numpy.byte_bounds() function â Python numpy.byte_bounds() function returns pointers to the end-points of an array. Syntax : numpy.byte_bounds(arr) Parameters : arr : [ndarray] Input array. Return : [tuple of 2 integers] The first integer is the first byte of the array, the second integer is just past the last byte of the array. If arr i 1 min read numpy.who function - Python numpy.who() function print the NumPy arrays in the given dictionary. Syntax : numpy.who(vardict = None) Parameters : vardict : [dict, optional] A dictionary possibly containing ndarrays. Return : Returns âNoneâ. If there is no dictionary passed in or vardict is None then returns NumPy arrays in the 1 min read numpy.rint() in Python The numpy.rint() is a mathematical function that rounds elements of the array to the nearest integer. Syntax : numpy.rint(x[, out]) = ufunc ârintâ) Parameters : array : [array_like] Input array. Return : An array with all array elements being rounded off, having same type and shape as input. Code #1 2 min read numpy.round_() in Python The round_() function in NumPy rounds the elements of an array to a specified number of decimal places. This function is extremely useful when working with floating-point numbers and when precision is important in scientific computing or data analysis.Syntax: numpy.round_(arr, decimals=0, out=None)P 3 min read numpy.where() in Python We will explore the basics of numpy.where(), how it works, and practical use cases to illustrate its importance in data manipulation and analysis.Syntax of numpy.where()Syntax :numpy.where(condition[, x, y]) Parameters condition: A condition that tests elements of the array.x (optional): Values from 3 min read numpy.apply_along_axis() in Python The numpy.apply_along_axis() function helps us to apply a required function to 1D slices of the given array. 1d_func(ar, *args) : works on 1-D arrays, where ar is 1D slice of arr along axis. Syntax : numpy.apply_along_axis(1d_func, axis, array, *args, **kwargs) Parameters : 1d_func : the required fu 3 min read numpy.outer() function - Python numpy.outer() function compute the outer product of two vectors. Syntax : numpy.outer(a, b, out = None) Parameters : a : [array_like] First input vector. Input is flattened if not already 1-dimensional. b : [array_like] Second input vector. Input is flattened if not already 1-dimensional. out : [nda 1 min read Like