NumPy cumsum returns every running total and makes the accumulation axis explicit
A final sum answers how much a collection adds up to. A cumulative sum also retains the total reached at every earlier position. Academia Master Trader explains NumPy cumsum in English for readers in Cyprus, using a short sequence and a small matrix. The examples are constructed arithmetic, not reported market observations. The aim is to distinguish individual entries from running totals and to keep the direction of accumulation clear.
Build a running total one entry at a time
After import numpy as np, define x = np.array([3,5,-2,4]). The call np.cumsum(x) returns [3,8,6,10]. The first result is three. The second adds five to that running total, giving eight. The third adds minus two, giving six. The fourth adds four, giving ten. The negative entry reduces the running total; the function does not force the output to rise.
Each output position contains the sum of all input entries up to and including that position. Four inputs therefore produce four cumulative outputs. This differs from an adjacent difference, which compares pairs and normally shortens a one dimensional sequence. It also differs from returning only the final sum, because the intermediate totals remain available.

Separate the contribution from the accumulated amount
The figure places the input entries in gold and their cumulative totals in grey. At the third position, the input contribution is minus two, while the accumulated amount is six. These are different quantities associated with the same position. A label should say whether it describes an entry or the running total through that entry.
The final total ten includes every contribution in the example. It is not a fifth input entry and should not be appended to the original sequence as though it were a new observation. When presenting an accumulated series, keep the original values available if readers need to explain which contribution changed the total at a particular step.
A matrix requires a direction
Define a = np.array([[3,5,2],[4,1,6]]), with shape (2,3). The call np.cumsum(a,axis=1) returns [[3,8,10],[4,5,11]]. Accumulation restarts for each row. In the first row, three becomes eight and then ten. In the second row, four becomes five and then eleven. The result keeps the matrix shape.
The call np.cumsum(a,axis=0) returns [[3,5,2],[7,6,8]]. Here each column has its own running total from the first row onward. The second row contains three plus four, five plus one, and two plus six. Changing the axis changes which entries are accumulated together, even though the input values and output shape remain the same.
The default flattens the matrix
Without an axis argument, np.cumsum(a) returns [3,8,10,14,15,21]. For this matrix, the flattened sequence reads the first row followed by the second row, and accumulation continues across the row boundary. Four is therefore added to ten, producing fourteen, rather than starting a separate row total at four.
That one dimensional result has six entries. Compare it with the two axis specific matrix results before choosing a form for an explanation. A familiar looking first total is not enough to establish that the intended grouping was used.
Choose an accumulator type that suits the values
The optional dtype argument controls the returned type and accumulator type. Integer overflow uses modular arithmetic, so large cumulative totals need a suitable integer capacity. Floating point accumulation can involve rounding, and its final value may differ slightly from a separately calculated sum that uses another summation approach. These are numerical properties, not evidence of additional input data.
Continue learning with Academia Master Trader at academiamastertrader.com.br and in Aprenda. Record the original entries, the axis or flattened order, the accumulator type and the output shape. Then follow several additions manually. Those checks make each running total explainable without confusing it with a separate contribution or a forecast.