floor()
Returns array with floor values of the elements.
floor : The highest integer lower 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.floor(ar))
Output
[ 1. 2. 2. -4. -4.]
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.floor(ar,out=ar_out)
print(ar_out)
Output ( the array ar_out stores the output values )
[ 1. 2. 2. -4. -4.]
where
We can exclude elements for which floor 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.floor(ar,where=ar_where))
Output (floor() is not applied to our 2nd and 4 elements of the input array )
[ 1. 2.09 2. -3.41 -4. ]
ceil()
«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