How to round elements of the NumPy array to the nearest integer? Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Prerequisites: Python NumPy In this article, let's discuss how to round elements of the NumPy array to the nearest integer. numpy.rint() function of Python that can convert the elements of an array to the nearest integer. Syntax: numpy.rint(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'rint'> Example 1: Python3 import numpy as n # create array y = n.array([0.2, 0.3, 0.4, 0.5, 0.6, 0.7]) print("Original array:", end=" ") print(y) # round to nearest integer y = n.rint(y) print("After rounding off:", end=" ") print(y) Output: Example 2: Python3 import numpy as n # create array y = n.array([-0.2, 0.7, -1.4, -4.5, -7.6, -19.7]) print("Original array:", end=" ") print(y) # round to nearest integer y = n.rint(y) print("After rounding off:", end=" ") print(y) Output: Comment More infoAdvertise with us Next Article How to get the floor, ceiling and truncated values of the elements of a numpy array? R romy421kumari Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads How to Convert NumPy Array of Floats into Integers In this article, we will see how to convert NumPy Array of Floats into Integers. We are given a NumPy array of float-type values. Our task is to convert all float-type values of Numpy array to their nearest array of integer values.Input: [1.2, 4.5, 9.1, 6.5, 8.9, 2.3, 1.2]Output: [1, 4, 9, 6, 8, 2, 4 min read How to Convert NumPy Array of Floats into Integers In this article, we will see how to convert NumPy Array of Floats into Integers. We are given a NumPy array of float-type values. Our task is to convert all float-type values of Numpy array to their nearest array of integer values.Input: [1.2, 4.5, 9.1, 6.5, 8.9, 2.3, 1.2]Output: [1, 4, 9, 6, 8, 2, 4 min read Find the nearest value and the index of NumPy Array In this article, let's discuss finding the nearest value and the index in an array with Numpy. We will make use of two of the functions provided by the NumPy library to calculate the nearest value and the index in the array. Those two functions are numpy.abs() and numpy.argmin(). Example Input Arra 3 min read Python | Filter out integers from float numpy array Given a numpy array, the task is to filter out integers from an array containing float and integers. Let's see few methods to solve a given task. Method #1 : Using astype(int) Python3 # Python code to demonstrate # filtering integers from numpy array # containing integers and float import numpy as 2 min read How to get the floor, ceiling and truncated values of the elements of a numpy array? In this article, let's discuss how to get the floor, ceiling, and truncated values of the elements of a Numpy array. First, we need to import the NumPy library to use all the functions available in it. This can be done with this import statement: import numpy as np Getting the floor value The greate 3 min read How to skip every Nth index of NumPy array ? NumPy arrays offer efficient numerical operations and data storage. When working with large arrays, sometimes it's necessary to skip specific indices for optimization or data processing purposes. This article will show how to skip every Nth index of the NumPy array. There are various ways to access 4 min read Like