numpy.ceil | Return the ceiling of the input
In this tutorial, we will learn how to use the ceiling function of numpy. In Python, to access arrays we have a module i.e numpy. As numpy works on arrays, we will find ceiling values for the elements in an array. Before this, one shall have basic knowledge about the ceiling of a number. You can know about the ceiling of a number in Python.
If you are clear about the concept of the ceiling of a number in Python, this thing with numpy is quite easy. Let’s directly hop on to the code.
import numpy as np arr=np.array([1.1,2.6,3.4,4.6,8.4567,9.4567145]) print(np.ceil(arr))
The code is quite simple to write as well as to understand. We have defined a simple array “arr” using numpy, then we have used our ceil function. What this ceil() does is, it takes the ceiling values of all the elements in the array and returns a new array.
output: [ 2. 3. 4. 5. 9. 10.]
It’s quite easy to understand and implement this concept.
This ceil function of numpy works only on one-dimensional arrays. As it has no functionalities of axes, it works on only one axis.
Leave a Reply