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.floor(ar))
Output
[ 1. 2. 2. -4. -4.]
import numpy as np
ar=np.array([1.57, 2.09, 2.79,-3.41,-3.62])
ar_out=np.empty_like(ar)
np.floor(ar,out=ar_out)
print(ar_out)
Output ( the array ar_out stores the output values )
[ 1. 2. 2. -4. -4.]
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.floor(ar,where=ar_where))
Output (floor() is not applied to our 2nd and 4[ 1. 2.09 2. -3.41 -4. ]
ceil()
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.