floor()

Numpy Math Functions

Returns array with floor values of the elements.

floor : The highest integer lower 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.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()


plus2net.com



Post your comments , suggestion , error , requirements etc here




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