Quick answer: np.fliplr reverses an array from left to right by reversing the second axis. It preserves shape, requires at least two dimensions, and may return a view with different strides, so verify axis intent and downstream memory assumptions.

numpy.fliplr() flips an array from left to right. In practical terms, it reverses the order of columns while keeping each row in the same vertical position. This makes it useful for matrices, table-shaped arrays, masks, grids, and two-dimensional numeric data.
The official NumPy documentation for numpy.fliplr() defines the function as a left-right flip for arrays with at least two dimensions. The related numpy.flip() function can flip along any selected axis, and numpy.reshape() is useful when one-dimensional input must become a two-dimensional array first.
The key rule is simple: use fliplr() when the leftmost column should become the rightmost column, the rightmost column should become the leftmost column, and the row order should stay unchanged. If you need to reverse rows instead, use flipud() or flip(..., axis=0).
Most confusion comes from array dimensions. fliplr() expects at least two dimensions. A plain one-dimensional array does not have columns, so NumPy raises an error. Reshape it first if the data should be treated as a row or column matrix.
It also helps to check the output shape before sending the result into plotting, modeling, or export code. A left-right flip normally keeps the same shape, but it changes positional meaning. Column labels, coordinate systems, and downstream assumptions should still match the new order.
Flip A 2D Array
The most common use is a two-dimensional array. The rows stay in place, but each row has its column order reversed.
try:
import numpy as np
except ModuleNotFoundError:
print("Install numpy to run this example.")
else:
data = np.array([
[1, 2, 3],
[4, 5, 6],
])
print(np.fliplr(data))
The first row becomes [3, 2, 1], and the second row becomes [6, 5, 4]. The top row remains the top row.
This is exactly what you want for a left-right mirror of matrix-style data. It is not a transpose, and it does not rotate the array.
Compare fliplr With Slicing
For a two-dimensional array, np.fliplr(data) is equivalent to reversing the second axis with slicing.
try:
import numpy as np
except ModuleNotFoundError:
print("Install numpy to run this example.")
else:
data = np.array([
[10, 20, 30],
[40, 50, 60],
])
left_right = np.fliplr(data)
sliced = data[:, ::-1]
print(np.array_equal(left_right, sliced))
The slice form is concise, but fliplr() communicates intent clearly. A reader can immediately see that the operation is a left-right flip.
Use the named function when readability matters, especially in tutorial code, transformation pipelines, or data-cleaning scripts that are reviewed by other people.

Use flip With Axis 1
numpy.flip() can do the same operation when you set axis=1. This is useful when the axis is selected programmatically.
try:
import numpy as np
except ModuleNotFoundError:
print("Install numpy to run this example.")
else:
data = np.array([
[1, 2],
[3, 4],
[5, 6],
])
print(np.flip(data, axis=1))
print(np.fliplr(data))
The two outputs match because axis 1 is the column axis in a normal two-dimensional array.
Choose flip() when the axis might change. Choose fliplr() when the operation is always a left-right column reversal.
Handle One-Dimensional Input
A one-dimensional array has no left and right columns. If you pass one directly, NumPy raises a value error.
try:
import numpy as np
except ModuleNotFoundError:
print("Install numpy to run this example.")
else:
values = np.array([1, 2, 3])
try:
np.fliplr(values)
except ValueError as error:
print(type(error).__name__)
row = values.reshape(1, 3)
print(np.fliplr(row))
Reshaping to (1, 3) turns the input into one row with three columns. After that, fliplr() has a clear column axis to reverse.
This is safer than forcing a flip without deciding whether the values represent one row, one column, or a flat sequence.
Understand View Behavior
For many arrays, fliplr() returns a view instead of copying all data. That is efficient, but it also means edits through the result may affect the original array.
try:
import numpy as np
except ModuleNotFoundError:
print("Install numpy to run this example.")
else:
data = np.array([
[1, 2, 3],
[4, 5, 6],
])
flipped = np.fliplr(data)
flipped[0, 0] = 99
print(flipped)
print(data)
Because the flipped result can share memory, use .copy() when you need an independent array that can be changed without affecting the source.
View behavior is a feature for performance, but it should be intentional in code that mutates data after flipping.

Flip Higher-Dimensional Arrays
fliplr() also works with arrays that have more than two dimensions. It still reverses axis 1, leaving the other axes in their existing order.
try:
import numpy as np
except ModuleNotFoundError:
print("Install numpy to run this example.")
else:
data = np.arange(12).reshape(2, 2, 3)
result = np.fliplr(data)
print(data.shape)
print(result.shape)
print(result[0])
The shape remains the same, but the entries along the second axis are reversed. This matters for stacked matrices, batches, or grid data with extra channels.
When working with more than two dimensions, write down which axis represents rows, columns, batches, or channels. Then choose fliplr(), flipud(), or flip() based on that axis meaning.
In short, np.fliplr() is the clear tool for reversing columns in arrays with at least two dimensions. It keeps row order intact, can return an efficient view, and is equivalent to a column-axis reversal.
For production code, keep a small test case that shows the before-and-after matrix. That simple test catches wrong-axis mistakes quickly and documents why the transformation is a left-right flip instead of a row reversal or transpose.
Understand The Axis
For a two-dimensional array, fliplr keeps each row intact while reversing the order of columns. With more dimensions, it still targets axis 1 rather than reversing every axis.

Check The Rank
A one-dimensional array has no second axis, so np.fliplr raises an error. Reshape or choose another operation only when that change matches the data model.
Compare Related Operations
Use np.flip with an explicit axis when axis choice should be visible, slicing when a simple two-dimensional reversal is sufficient, and rot90 only for a rotation rather than a mirror.
Consider Views And Strides
The result can share storage with the input and expose reversed strides. Read-only use is straightforward, but code that assumes contiguous memory should make that assumption explicit.

Preserve Shape And Dtype
fliplr changes ordering, not shape or element dtype. Check those invariants when the result enters a serializer, image pipeline, matrix calculation, or compiled extension.
Test Representative Arrays
Test a two-dimensional matrix with unique values, a higher-dimensional array, a singleton dimension, an empty dimension, dtype preservation, expected shape, and a one-dimensional input that should fail clearly.
Use the official NumPy fliplr documentation for axis and view behavior. Related Python Pool references include NumPy arrays and testing.
For related array transformations, compare NumPy shapes, axis tests, and sequence order before flipping data.
Frequently Asked Questions
What does NumPy fliplr do?
np.fliplr reverses the order of elements along the second axis, so a two-dimensional array’s columns appear from right to left.
Does fliplr change the shape?
No. The output has the same shape as the input, although its memory layout and view behavior should be considered in downstream code.
Can I use fliplr on a one-dimensional array?
No. fliplr requires an array with at least two dimensions because it operates on the second axis.
Is NumPy fliplr the same as reversing every axis?
No. fliplr reverses columns only; use an operation whose axis semantics match the intended transformation when working with higher-dimensional data.