ceil()

Returns array with ceil values of the elements.

ceil : The lowest integer higher than the input number.
aInput array with numbers
outOptional , ndarray to store result
whereOptional , 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



plus2net.com







Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer