NumPy roll moves entries cyclically and brings boundary values back into the array
Moving array entries can mean either discarding boundary values or wrapping them around. NumPy roll uses the second interpretation: entries that pass one boundary return at the other. Academia Master Trader explains this cyclic operation in English for readers in the Netherlands. Small constructed examples show how the shift direction and selected axis determine the output, without treating a rearranged sequence as a new collection of observations.
A positive shift moves entries toward higher positions
After import numpy as np, define x = np.array([2,5,8,11]). The call np.roll(x,1) returns [11,2,5,8]. Two moves from index zero to index one, five moves to index two and eight moves to index three. Eleven wraps from the final position back to index zero.
No entry is removed and no empty position is created. The array still contains four values. This makes roll different from an operation that inserts a blank or a missing value at the beginning. The boundary behaviour is part of the operation, not an optional interpretation to choose after seeing the output.

A negative shift reverses the direction
The call np.roll(x,-1) returns [5,8,11,2]. Five moves to index zero, while two wraps to the final position. A shift of two returns [8,11,2,5]. The sign sets the direction and the magnitude sets how many positions each entry moves.
A shift equal to this vector's length restores its original arrangement. Thus np.roll(x,4) returns [2,5,8,11]. A shift of five has the same result as a shift of one. These comparisons help explain that a cyclic shift follows a repeating positional cycle rather than continually extending the array.
The default handles a matrix through its flattened order
Define a = np.array([[1,2,3],[4,5,6]]). The call np.roll(a,1) returns [[6,1,2],[3,4,5]]. By default, NumPy flattens the input before rolling and then restores the original shape. The result therefore still has two rows and three columns.
Six returns to the first position of the flattened sequence, and three crosses from the end of the original first row into the beginning of the second row. This is not the same as shifting each row independently. State whether an axis was supplied before describing how the matrix boundaries behave.
An explicit axis defines separate cyclic paths
The call np.roll(a,1,axis=1) returns [[3,1,2],[6,4,5]]. Each row rolls horizontally within itself. Three wraps to the first position of its row, while six does the same in the second row. Values do not cross between rows in this example.
The call np.roll(a,1,axis=0) returns [[4,5,6],[1,2,3]]. Complete rows exchange vertical positions because there are only two rows. The output shape remains two by three in both cases. Shape alone therefore cannot tell you which path each value followed; the axis is needed as well.
Explain wrapped entries before using the result
For a time ordered record, a cyclic shift places a value from one end next to values from the other. That can suit a deliberately periodic construction, but it is not a blank filled lag. The wrapped entry remains a real number from the input and should be identified as such when explaining the rearrangement.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Record the input shape, shift and axis, then trace one interior entry and one boundary entry. Check that the output keeps the original shape and that every wrapped value goes where the cyclic rule requires. This keeps positional rearrangement distinct from adding or predicting data.