NumPy repeat places repeated entries together along a selected axis
Repeating individual entries creates a different order from repeating a complete pattern. NumPy repeat places the requested number of occurrences of each entry together. Academia Master Trader presents this English lesson for readers in Palestine, using constructed arrays to explain uniform counts, different counts for different positions and the effect of choosing an axis explicitly.
Begin with one count for every vector entry
After import numpy as np, define v = np.array([3,7,11]). The call np.repeat(v,2) returns [3,3,7,7,11,11], with shape (6,).
Each input entry appears twice in succession. The result is not [3,7,11,3,7,11], which would repeat the whole sequence as a pattern. Write the intended output order before choosing between entry repetition and pattern tiling. The same total number of positions does not make those arrangements equivalent.

Counts can differ across positions
The call np.repeat(v,[1,2,3]) returns [3,7,7,11,11,11]. Three appears once, seven appears twice and eleven appears three times. Each count corresponds to the input position in the same order.
The counts describe total occurrences in the result, not additional copies beyond the original. A count of one therefore keeps one occurrence. A count of zero contributes no occurrence from that position. For example, np.repeat(v,[1,0,2]) returns [3,11,11]. Sum the counts to check the output length in this one dimensional case.
An explicit axis preserves the other dimensions
Define m = np.array([[2,5],[8,11]]). The call np.repeat(m,2,axis=1) returns [[2,2,5,5],[8,8,11,11]], with shape (2,4).
Axis one identifies column positions in this matrix. Each position is repeated along that axis, while the two row positions remain. Using np.repeat(m,2,axis=0) instead gives [[2,5],[2,5],[8,11],[8,11]], with shape (4,2). Whole rows repeat because the chosen axis is now the row axis.
Different row counts repeat complete row slices
The call np.repeat(m,[1,2],axis=0) returns [[2,5],[8,11],[8,11]], with shape (3,2). The first row occurs once and the second row occurs twice.
This example shows why the axis is part of the meaning, not just an optional formatting detail. Counts correspond to positions along that axis. Every slice attached to a repeated position moves together, so the two values within the second row retain their order in both occurrences.
For the row count example, adding one and two gives three output rows, each still containing two entries. For the uniform column example, each of the two input columns contributes two positions, giving four columns. These small checks connect the count parameters to the dimensions instead of relying only on a printed result.
Omitting axis produces a flat result
The call np.repeat(m,2) returns [2,2,5,5,8,8,11,11], with shape (8,). NumPy uses the flattened input and returns a flat output when axis is omitted. It does not restore the original matrix shape afterward.
Keep the output shape beside the repeated values, especially when the next calculation expects rows and columns. Repetition changes the number of positions; it does not add the repeated numbers together or calculate a new value for them.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. State the counts, selected axis and output order whenever you explain a repeated array.