Numpy: fliplr() function
numpy.fliplr() function
The fliplr() function is used to flip array in the left/right direction.
Flip the entries in each row in the left/right direction. Columns are preserved, but appear in a different order than before.
Syntax:
numpy.fliplr(m)
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
m | Input array, must be at least 2-D. | Required |
Return value:
ndarray - A view of m with the columns reversed. Since a view is returned, this operation is \mathcal O(1).
Example-1: numpy.fliplr()
>>> import numpy as np
>>> X = np.diag([1.,2.,3.,4.])
>>> X
array([[ 1., 0., 0., 0.],
[ 0., 2., 0., 0.],
[ 0., 0., 3., 0.],
[ 0., 0., 0., 4.]])
Pictorial Presentation:
Example-2: numpy.fliplr()
>>> import numpy as np
>>> X = np.diag([1.,2.,3.,4.])
>>> np.fliplr(X)
array([[ 0., 0., 0., 1.],
[ 0., 0., 2., 0.],
[ 0., 3., 0., 0.],
[ 4., 0., 0., 0.]])
Pictorial Presentation:
Example-3: numpy.fliplr()
>>> import numpy as np
>>> X = np.random.randn(3,5,7)
>>> np.all(np.fliplr(X) == X[:,::-1,...])
True
Python - NumPy Code Editor:
Previous: Rearrangeing elements flip()
Next: flipud()
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework