I trying to something like array ( DataFrame or Series or array ) using loop but it still be failed.
Here is my code.
for index, city in enumerate(ser_region):
print(index, region_csv[region_csv["province"] == city].confirmed.sum())
s = pd.Series([region_csv[region_csv["province"] == city].confirmed.sum()])
s
0 81923
1 16341
2 807506
3 16645
4 3359
5 5217
6 5269
7 5111
8 81059
9 5908
10 5801
11 16780
12 2108
13 1763
14 161079
15 13860
16 1449
0 1449
dtype: int64
region_csv
date time province confirmed released deceased
0 2020-01-20 16 Seoul 0 0 0
1 2020-01-20 16 Busan 0 0 0
2 2020-01-20 16 Daegu 0 0 0
3 2020-01-20 16 Incheon 1 0 0
4 2020-01-20 16 Gwangju 0 0 0
... ... ... ... ... ... ...
2766 2020-06-30 0 Jeollabuk-do 27 21 0
2767 2020-06-30 0 Jeollanam-do 24 19 0
2768 2020-06-30 0 Gyeongsangbuk-do 1389 1328 54
2769 2020-06-30 0 Gyeongsangnam-do 134 128 0
2770 2020-06-30 0 Jeju-do 19 16 0
2771 rows × 6 columns
ser_region = pd.Series(region_csv['province'].unique()); ser_region
0 Seoul
1 Busan
2 Daegu
3 Incheon
4 Gwangju
5 Daejeon
6 Ulsan
7 Sejong
8 Gyeonggi-do
9 Gangwon-do
10 Chungcheongbuk-do
11 Chungcheongnam-do
12 Jeollabuk-do
13 Jeollanam-do
14 Gyeongsangbuk-do
15 Gyeongsangnam-do
16 Jeju-do
dtype: object
How can I solve it ?
N why I try to do that is 'Rank the regions/provinces in descending order based on the total number of cases'.
My thought was do sum eq by province. and put it in DataFrame or Series or array. and rank it. But I failed.