Python | Numpy ndarray .__ irshift __ ()



Using the numpy.ndarray.__irshift__() method, we can get elements that are shifted to the right by the value specified as a parameter in numpy.ndarray. __irshift __ () .

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

Return: self & gt; & gt; = value

Example # 1:
In this example, we see that each element is shifted to the right by a value, passed as a parameter to ndarray .__ irshift __ () .

# import important module in python

import numpy as np

  
# make an array with NumPy

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

 
# applying the ndarray method .__ irshift __ ()

print (gfg .__ irshift __ ( 2 ))

Exit:

 [0 0 0 1 1] 

Example # 2:

# import important module into python

import numpy as np

 
# make an array with NumPy

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

[ 6 , 5 , 4 , 3 , 2 ]])

 
# applying the ndarray .__ irshift __ () method

print (gfg .__ irshift __ ( 1 ))

Exit:

 [[0 1 1 2 2] [3 2 2 1 1]]