Facebook Page Twitter Page LinkedIn Page
× NumPy Tutorial NumPy Resources

The NumPy ceil() function is used to return the ceiling value of the input data. The ceiling of the scalar x is the smallest integer i, such that i >= x.


numpy.ceil(a, out=None)


a Required. Specify array (array_like) containing elements, of which the ceiling value is calculated.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns the ceiling value of each element of a.


In the below example, numpy ceil() function is used to calculate the ceiling value of each element present in array Arr.

import numpy as np

Arr = np.array([0.65, 6.56, 52.67, 167.23])
print("Original Array:")

print("\nCeiling value array:")

The output of the above code will be:

Original Array:
[   0.65    6.56   52.67  167.23]

Ceiling value array:
[   1.    7.   53.  168.]

❮ NumPy - Functions