The ceil
function calculates the element-wise ceiling of a given set of numerical values.
The ceil of a number x, which is scalar, is the smallest integer i, such that i >= x.
numpy.ceil(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'ceil'>
A universal function (ufunc) is a function that operates on ndarrays in an element-by-element fashion. The
ceil
method is a universal function.
The ceiling
function accepts the following arguments:
x
- array-like structure on the contents of the ceiling
function will be applied.out
(optional) - the function’s output is stored at this location.where
(optional)- if set True, a universal function is calculated at this position.casting
(optional)- enables the user to decide how the data will be cast. If set as same_kind, safe casting will take place.order
(optional)- determines the memory layout of the output. For example, if set as K, the function reads data in the order they are written in memory.dtype
(optional) - the data type of the arraysubok
(optional) - to pass subclasses, subok
must be set as True.The ceil
function returns the corresponding values, of type float, in an ndarray.
If x is scalar, the return value is scalar as well.
The example below demonstrates how to apply the ceil
function on an array containing decimal values.
import numpyval = [1.2, 1.9, 2.1, -6.5, -6.2, -5.9]ceil_val = numpy.ceil(val)print(ceil_val)
Free Resources