Q. Write command to print cumulative sum of columns Rainfall and Evaporation in the dataframe wdf given below.
minTemp maxTemp Rainfall Evaporation 0 1 8.0 24.3 0.0 1 2 14.0 26.9 3.6 2 3 13.7 23.4 3.6 3 4 13.3 15.5 39.8 4 5 7.6 16.1 2.8 5 6 6.2 16.9 0.0 6 7 6.1 18.2 0.2 7 8 8.3 17.8 0.0 8 9 8.8 19.5 0.0 9 10 8.4 22.8 16.2 10 11 9.1 25.2 0.0 11 12 8.5 27.3 0.2 12 13 10.1 27.9 0.0 13 14 12.1 30.9 0.0 14 15 10.1 31.2 0.0 15 16 12.4 32.1 0.0 16 17 13.8 31.2 0.0 17 18 11.7 30.0 1.2 18 19 12.4 32.3 0.6 19 20 15.6 33.4 0.0 20 21 15.3 33.4 0.0
Answer :-
wdf[["Rainfall", "Evaporation"]].apply(np.cumsum)
Rainfall Evaporation
0 24.3 0.0
1 51.2 3.6
2 74.6 7.2
3 90.1 47.0
4 106.2 49.8
5 123.1 49.8
6 141.3 50.0
7 158.3 50.0
8 177.8 50.0
9 200.6 66.2
10 225.8 66.2
11 253.1 66.4
12 281.0 66.4
13 311.9 66.4
14 343.1 66.4
15 375.2 66.4
16 406.4 66.4
17 436.4 67.6
18 468.7 68.2
19 502.1 68.2
20 535.5 68.2
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )