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 |
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.]
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.]
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[ 2. 2.09 3. -3.41 -3. ]
floor()
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.