NumPy expand_dims inserts a new axis at a chosen position in the expanded shape
A sequence of two values and a table with one row of two values contain the same number of elements, but they have different shapes. NumPy expand_dims makes this distinction explicit. It inserts a new axis at a selected position in the expanded shape. The result has more dimensions, and the position of the inserted axis determines how the existing values are arranged within that shape.
Academia Master Trader presents this guide in English for readers in Malaysia. The small arrays are educational examples for reading dimensions and brackets. They do not represent market prices or financial results. Following the shapes alongside the values makes the operation easier to describe than relying on the visual direction of a printed array alone.
Begin with a one dimensional array
The official reference uses x=np.array([1,2]). Its shape is (2,).
That shape has one entry, so the array has one dimension. The entry says that the existing axis has length two. The comma in the tuple notation is meaningful; it helps show that this is a shape tuple containing one length.
Neither of the next examples changes the two displayed values into a different sequence. Their difference is where the additional axis appears.

Axis zero inserts a length one axis first
The call np.expand_dims(x,axis=0) produces an array displayed as [[1,2]]. Its shape is (1,2) in the documentation.
Read the shape from the beginning. The inserted axis has length one, followed by the existing length two. In a two dimensional display, that gives one row containing two entries.
The number of dimensions has increased from one to two. The number of values remains two. These are different quantities, so an explanation should not use the word size when it really means the number of axes.
Axis one inserts the new axis after the existing one
The call np.expand_dims(x,axis=1) produces the two dimensional arrangement [[1],[2]]. The reference gives its shape as (2,1).
Now the existing length two comes first, followed by the inserted length one. The display has two rows, with one entry in each row.
Both (1,2) and (2,1) describe arrays with two values. They are not interchangeable descriptions of the same shape. The choice of axis is the reason the arrangements differ.
Read axis as a position in the expanded shape
The reference defines axis as the position in the expanded axes where the new axis is placed. This is more precise than describing it as a selection of an existing row or column.
For the one dimensional input, axis zero creates the leading position and axis one creates the following position. Those choices produce a result with two axes.
Write the input shape, then write the intended output shape before explaining the call. This simple comparison keeps the new length one separate from the original length two, especially when several surrounding brackets are visible.
A tuple can insert several axes
The axis parameter can be an integer or a tuple of integers. The documentation includes np.expand_dims(x,axis=(0,1)), whose displayed result is [[[1,2]]].
It also includes np.expand_dims(x,axis=(2,0)), with displayed result [[[1],[2]]].
The tuple describes positions for new axes. It is not a tuple of data values to append to the array, nor a list of replacement lengths for the original axis.
With several inserted axes, follow the nesting of brackets carefully. Keep the exact axis tuple beside the example rather than describing every three dimensional result as though it had the same arrangement.
The result is a view
The reference describes the returned array as a view of the input, with the number of dimensions increased.
That return description is part of the function's behaviour. Do not describe the operation as a promise of an independent copy merely because the printed output has a new shape.
A shape change and a copy are separate ideas. Naming the result as a view gives the reader the documented relationship without inventing an extra data duplication step.
Related notation helps connect the examples
For axis zero, the reference gives equivalent indexing forms using x[np.newaxis,:] or x[np.newaxis]. For axis one, it gives x[:,np.newaxis].
These forms connect the new axis position with familiar indexing notation. The reference also notes that np.newaxis and None are the same object.
Continue learning with Academia Master Trader at academiamastertrader.com.br. Aprenda gives access to educational resources. Keep the input shape, inserted positions and output shape together in your notes. Expand dims adds axes; the examples show why the location of a new length one matters even when the original values stay easy to recognise.