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 & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.