NumPy repeat duplicates entries consecutively along a selected array axis
Repeating entries changes the arrangement and size of an array without creating new observations. NumPy repeat places copies of each entry consecutively along a selected axis. Academia Master Trader presents this English lesson for readers in Laos. Constructed examples distinguish element repetition, row repetition and a flattened result, so the returned values can be connected to the exact rule that created them.
Repeat each entry before moving on
After import numpy as np, define a = np.array([2,5,8]). The call np.repeat(a,2) returns [2,2,5,5,8,8]. Two appears twice, then five appears twice, then eight appears twice. The count two applies to each input entry, giving six output entries from three source entries.
This is not the arrangement [2,5,8,2,5,8]. That arrangement repeats the whole sequence as a block. Repeat instead places the copies of each entry together before moving to the next entry. State which arrangement is needed before choosing an operation, particularly when both arrangements contain the same collection of values.

Counts can differ by position
The call np.repeat(a,[1,3,2]) returns [2,5,5,5,8,8]. The first entry appears once, the second appears three times, and the third appears twice. The count array specifies repetitions associated with input positions, not output values to insert.
A zero count leaves no copies of that entry in the result. For example, np.repeat(a,[1,0,2]) returns [2,8,8]. Five remains in the original a but contributes no output entry in this call. Track the count rule alongside the source if later work must explain why some entries appear more often than others.
No axis means a flat output
Define m = np.array([[1,4],[7,9]]). The default call np.repeat(m,2) returns [1,1,4,4,7,7,9,9]. Without an axis argument, NumPy uses the flattened input and returns a one dimensional array. The original matrix shape (2,2) is not retained in that result.
The values follow the flattened arrangement: one and four from the first row, then seven and nine from the second. Each value is repeated in its turn. A flat output does not, by itself, preserve a separate row boundary. Keep the original shape when those boundaries carry meaning.
An explicit axis repeats rows or columns
The call np.repeat(m,2,axis=0) returns [[1,4],[1,4],[7,9],[7,9]]. It repeats each row consecutively, so the shape changes from (2,2) to (4,2). The columns remain paired within their corresponding rows.
The call np.repeat(m,2,axis=1) returns [[1,1,4,4],[7,7,9,9]]. This repeats the entries along the column direction within each row, producing shape (2,4). Axis zero and axis one therefore create different layouts even when the repetition count is the same.
Counts can also vary along the chosen axis. The call np.repeat(m,[1,2],axis=0) returns [[1,4],[7,9],[7,9]]. The first row appears once and the second twice. Check that the count arrangement fits the selected axis rather than assuming it describes every individual matrix entry.
Copies do not add independent evidence
Repeated values may help construct a required layout, but their presence does not establish additional measurements or independent cases. A longer array can still come entirely from the same small source. Keep the transformation separate from any interpretation of sample size or frequency.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Record the source shape, chosen axis, repetition counts and output shape. Those details explain how the copies were arranged without assigning new meaning to duplicated values.