sum after joining and grouping by teams:
ipl=pd.concat([ipl17,ipl18]).groupby('Team').sum().reset_index()
print(ipl)
Output:
Team Matches Won Lost Tied N/R Points NRR For Against
0 CSK 14 9 5 0 0 18 0.253 2488 2433
1 DD 28 11 17 0 0 22 -0.734 4516 4559
2 GL 14 4 10 0 0 8 -0.412 2406 2472
3 KKR 28 16 12 0 0 32 0.571 4692 4725
4 KXIP 28 13 15 0 0 26 -0.379 4417 4488
5 MI 28 16 12 0 0 32 1.101 4787 4524
6 RCB 28 9 18 0 1 19 -1.170 4167 4416
7 RPS 14 9 5 0 0 18 0.176 2180 2165
8 RR 14 7 7 0 0 14 -0.250 2130 2141
9 SRH 28 17 10 0 1 35 0.753 4451 4311
Explanation:
Using concat
join the two dataframe
. using groupby('name')
are grouped by Team
. Subsequently, the sum is obtained for each team. Then reset_index
is used to transform the index
(Team) into columns
. If you prefer the latter you can skip it.