Calculate and plot cumulative figures

```
ykishi@dezembro pandas-test % cat cumsum-test.csv
date,apple,orange
2021-04-05,600,192
2021-04-06,5050,229
2021-04-07,0,0
2021-04-08,0,0
2021-04-09,50,2229
2021-04-10,0,0
2021-04-11,50,4524
2021-04-12,0,0
2021-04-13,0,0
2021-04-14,0,0
2021-04-15,0,8000
2021-04-16,0,0
2021-04-17,0,0
2021-04-18,0,0
2021-04-19,0,0
2021-04-20,0,0
2021-04-21,450,5900
2021-04-22,0,0
2021-04-23,0,0
2021-04-24,0,0
2021-04-25,4500,15900
2021-04-26,0,0
2021-04-27,0,0
2021-04-28,1,34
2021-04-29,300,155
2021-04-30,0,0
2021-05-01,8999,6660
ykishi@dezembro pandas-test % 
```

```
ykishi@dezembro pandas-test % cat cumsum-test.py                
#!/usr/bin/env python3

import datetime
import matplotlib.dates as mdates
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('cumsum-test.csv')
print(df)

#
# 累計値を求めて新たな列を追加する
#
df_new = df.cumsum()
print(df_new)

df['apple_cumulative'] = df_new['apple']
df['orange_cumulative'] = df_new['orange']
print(df)

#
# 描画する
#
df.plot(x="date")

plt.title("Cumulatives")
plt.xticks(rotation=90)
plt.grid(True, linestyle='dotted', linewidth=1)
plt.subplots_adjust(bottom=0.2, top=0.9)

plt.savefig("cumsum.png")
ykishi@dezembro pandas-test % ./cumsum-test.py ; open cumsum.png
          date  apple  orange
0   2021-04-05    600     192
1   2021-04-06   5050     229
2   2021-04-07      0       0
3   2021-04-08      0       0
4   2021-04-09     50    2229
5   2021-04-10      0       0
6   2021-04-11     50    4524
7   2021-04-12      0       0
8   2021-04-13      0       0
9   2021-04-14      0       0
10  2021-04-15      0    8000
11  2021-04-16      0       0
12  2021-04-17      0       0
13  2021-04-18      0       0
14  2021-04-19      0       0
15  2021-04-20      0       0
16  2021-04-21    450    5900
17  2021-04-22      0       0
18  2021-04-23      0       0
19  2021-04-24      0       0
20  2021-04-25   4500   15900
21  2021-04-26      0       0
22  2021-04-27      0       0
23  2021-04-28      1      34
24  2021-04-29    300     155
25  2021-04-30      0       0
26  2021-05-01   8999    6660
                                                 date  apple  orange
0                                          2021-04-05    600     192
1                                2021-04-052021-04-06   5650     421
2                      2021-04-052021-04-062021-04-07   5650     421
3            2021-04-052021-04-062021-04-072021-04-08   5650     421
4   2021-04-052021-04-062021-04-072021-04-082021-0...   5700    2650
5   2021-04-052021-04-062021-04-072021-04-082021-0...   5700    2650
6   2021-04-052021-04-062021-04-072021-04-082021-0...   5750    7174
7   2021-04-052021-04-062021-04-072021-04-082021-0...   5750    7174
8   2021-04-052021-04-062021-04-072021-04-082021-0...   5750    7174
9   2021-04-052021-04-062021-04-072021-04-082021-0...   5750    7174
10  2021-04-052021-04-062021-04-072021-04-082021-0...   5750   15174
11  2021-04-052021-04-062021-04-072021-04-082021-0...   5750   15174
12  2021-04-052021-04-062021-04-072021-04-082021-0...   5750   15174
13  2021-04-052021-04-062021-04-072021-04-082021-0...   5750   15174
14  2021-04-052021-04-062021-04-072021-04-082021-0...   5750   15174
15  2021-04-052021-04-062021-04-072021-04-082021-0...   5750   15174
16  2021-04-052021-04-062021-04-072021-04-082021-0...   6200   21074
17  2021-04-052021-04-062021-04-072021-04-082021-0...   6200   21074
18  2021-04-052021-04-062021-04-072021-04-082021-0...   6200   21074
19  2021-04-052021-04-062021-04-072021-04-082021-0...   6200   21074
20  2021-04-052021-04-062021-04-072021-04-082021-0...  10700   36974
21  2021-04-052021-04-062021-04-072021-04-082021-0...  10700   36974
22  2021-04-052021-04-062021-04-072021-04-082021-0...  10700   36974
23  2021-04-052021-04-062021-04-072021-04-082021-0...  10701   37008
24  2021-04-052021-04-062021-04-072021-04-082021-0...  11001   37163
25  2021-04-052021-04-062021-04-072021-04-082021-0...  11001   37163
26  2021-04-052021-04-062021-04-072021-04-082021-0...  20000   43823
          date  apple  orange  apple_cumulative  orange_cumulative
0   2021-04-05    600     192               600                192
1   2021-04-06   5050     229              5650                421
2   2021-04-07      0       0              5650                421
3   2021-04-08      0       0              5650                421
4   2021-04-09     50    2229              5700               2650
5   2021-04-10      0       0              5700               2650
6   2021-04-11     50    4524              5750               7174
7   2021-04-12      0       0              5750               7174
8   2021-04-13      0       0              5750               7174
9   2021-04-14      0       0              5750               7174
10  2021-04-15      0    8000              5750              15174
11  2021-04-16      0       0              5750              15174
12  2021-04-17      0       0              5750              15174
13  2021-04-18      0       0              5750              15174
14  2021-04-19      0       0              5750              15174
15  2021-04-20      0       0              5750              15174
16  2021-04-21    450    5900              6200              21074
17  2021-04-22      0       0              6200              21074
18  2021-04-23      0       0              6200              21074
19  2021-04-24      0       0              6200              21074
20  2021-04-25   4500   15900             10700              36974
21  2021-04-26      0       0             10700              36974
22  2021-04-27      0       0             10700              36974
23  2021-04-28      1      34             10701              37008
24  2021-04-29    300     155             11001              37163
25  2021-04-30      0       0             11001              37163
26  2021-05-01   8999    6660             20000              43823
ykishi@dezembro pandas-test % 
```
![cumsum.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1182287/7dbe170b-69a1-0cc2-5f80-14c1843db487.png)