Python | Numpy numpy.ndarray .__ floordiv __ ()

Numpy numpy.ndarray .__ floordiv __ () can strip a specific value provided as a parameter in ndarray .__ floordiv __ () . The value will be split into each array element and remember that it always gives the minimum value after division.

Syntax: ndarray .__ floordiv __ ($ self, value, /)

Return: self // value

Example # 1 :
In this example, we see that each element in the array is divisible with the value given as a parameter in the ndarray .__ floordiv __ () method and gives the minimum value of each element that split in an array. This method will work well for positive, negative and floating point array values.

# import important module into python

import numpy as np

 
# make an array with NumPy

gfg = np.array ([ 1 , 2.5 , 3 , 4.8 , 5 ])

 
# applying the ndarray method .__ floordiv __ () < / code>

print (gfg .__ floordiv __ ( 2 ))

Output:

 [0. 1. 1. 2. 2.] 

Example # 2:

# import important module in python

import numpy as np

 
# make an array with NumPy

gfg = np.array ([[ 1 , 2 , 3 , 4.45 , 5 ],

[ 6 , 5.5 , 4 , 3 , 2.62 ]])

  
# applying the ndarray method .__ floordiv __ ()

print (gfg .__ floordiv __ ( 3 ))

Exit :

 [[0. 0. 1. 1. 1.] [2. 1. 1. 1. 0.]]