NumPy repeat expands individual entries according to explicit repetition counts
Repeating a value changes how an array represents a sequence without creating new observations. NumPy repeat provides a direct way to make consecutive copies of individual entries or selected rows and columns. Academia Master Trader explains this operation in English for readers in Spain. Small constructed arrays make the order visible, so the repeated output can be traced back to its source rather than mistaken for additional independent information.
Begin with consecutive copies of each entry
After import numpy as np, define x = np.array([3,7,2]). The call np.repeat(x,2) returns [3,3,7,7,2,2]. Each original entry is written twice before the operation moves to the next entry. The first pair comes from three, the second pair from seven and the third pair from two.
This is different from repeating the complete sequence as a block. The result is not [3,7,2,3,7,2]. The distinction matters whenever order carries meaning. Describe whether the operation repeats each entry or an entire pattern before interpreting the expanded array. Here the repeated neighbours share the same source entry.

Give different entries different counts
The call np.repeat(x,[1,3,2]) returns [3,7,7,7,2,2]. The first count one belongs to three, the second count three belongs to seven and the third count two belongs to two. The count vector aligns with the input positions, not with the numerical magnitudes of the values.
The output length is six because the counts sum to six. A repetition count of one keeps one copy; it does not add one extra copy to an automatically retained original. A count of zero contributes no entries. For example, np.repeat(x,[1,0,2]) returns [3,2,2]. This makes the meaning of each count explicit.
The default flattens a matrix
Define a = np.array([[1,4],[6,8]]). Without an axis, np.repeat(a,2) returns [1,1,4,4,6,6,8,8]. The matrix entries are taken in flattened order, then each is repeated twice. The output is one dimensional, even though the input had two dimensions.
The original row grouping is therefore not retained in the output shape. When writing an explanation or a calculation, record that shape change alongside the values. An eight entry vector and a matrix containing eight entries may hold related numbers while supporting different later operations.
An axis keeps the other dimensions intact
For the same matrix, np.repeat(a,2,axis=0) returns [[1,4],[1,4],[6,8],[6,8]]. The first row is repeated twice, then the second row is repeated twice. The output shape is four rows by two columns. The column count stays unchanged.
By contrast, np.repeat(a,2,axis=1) returns [[1,1,4,4],[6,6,8,8]]. Each column position is repeated along the horizontal axis, giving two rows by four columns. Both outputs contain eight entries, but their shapes and groupings differ. Naming only the total number of entries would leave out that distinction.
Check counts against the selected axis
The call np.repeat(a,[1,2],axis=0) returns [[1,4],[6,8],[6,8]]. The two counts correspond to the two input rows. The first row contributes once and the second contributes twice. With an explicit axis, interpret a count vector against positions on that axis rather than against every scalar entry in the matrix.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Write down the input shape, repetition counts and axis before tracing the result. Then check the output shape and entry order. Repeated entries are copies defined by the operation, not evidence that the underlying event happened more often.