ceil()
Returns array with ceil values of the elements.
ceil : The lowest integer higher than the input number.
a | Input array with numbers |
out | Optional , ndarray to store result |
where | Optional , array with True to get values and False to leave the value |
Examples
We will use the options in our sample scripts.
import numpy as np
ar=np.array([1.57, 2.09, 2.79,-3.41,-3.62])
print(np.ceil(ar))
Output
[ 2. 3. 3. -3. -3.]
out
We can store the output in an array. We used empty_like() to create array (ar_out) of same shape() of our main array ar.
import numpy as np
ar=np.array([1.57, 2.09, 2.79,-3.41,-3.62])
ar_out=np.empty_like(ar)
np.ceil(ar,out=ar_out)
print(ar_out)
Output ( the array ar_out stores the output values )
[ 2. 3. 3. -3. -3.]
where
We can exclude elements for which ceil value is not required. This we can decide by using another array filled with True and False.
import numpy as np
ar=np.array([1.57, 2.09, 2.79,-3.41,-3.62])
ar_where=np.array([True,False,True,False,True])
print(np.ceil(ar,where=ar_where))
Output (ceil() is not applied to our 2nd and 4 elements of the input array )
[ 2. 2.09 3. -3.41 -3. ]
floor()
«Numpy
rad2deg()
bincount()
arange()
linspace()
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com