NumPy ndarray.__ilshift__() | Shift NumPy Array Elements to Left
Last Updated :
05 Feb, 2024
The ndarray.__ilshift__() method is an in-place left-shift operation. It shifts elements in the array to the left of the number of positions specified.
Example
Python3
import numpy as np
gfg = np.array([ 1 , 2 , 3 , 4 , 5 ])
print (gfg.__ilshift__( 2 ))
|
Syntax
Syntax: ndarray.__ilshift__($self, value, /)
Parameters
- self: The numpy array.
- value: The number of positions to shift.
Return: The array with its elements shifted left side
How to Shift Elements of NumPy Array to the left
To shift the elements of the NumPy Array to the left we use ndarray.__ilshift__() method of the NumPy library in Python.
Let’s understand it better with an example:
Example:
Python3
import numpy as np
gfg = np.array([[ 1 , 2 , 3 , 4 , 5 ],
[ 6 , 5 , 4 , 3 , 2 ]])
print (gfg.__ilshift__( 1 ))
|
Output
[[ 2 4 6 8 10]
[12 10 8 6 4]]
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...