32

Pitching yorkpy…on the middle and outside off-stump to IPL – Part 2

 5 years ago
source link: https://www.tuicool.com/articles/hit/ANzYRbj
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

When you come to a fork in the road, take it.

You’ve got to be very careful if you don’t know where you are going, because you might not get there

Yogi Berra

Try taking his (Rahul Dravid’s) wicket in the first 15 minutes. If you can’t then only try to take the remaining wickets

Steve Waugh

Introduction

This post is a follow-up to my previous post, Pitching yorkpy…short of good length to IPL-Part 1 , in which I analyzed individual IPL matches. In this 2nd post I analyze the data in all matches between any 2 IPL teams, say CSK-RCB, MI-KKR or DD-RPS and so on. As I have already mentioned  yorky is the python clone of my R packkage  yorkr and this post is almost a mirror image of my post with yorkr namely  yorkr crashes the IPL party! – Part 2 . The signatures of yorkpy and yorkr are identical and will work in amost the same way.

You can clone/download the code at Github yorkpy

This post has been published to RPubs at  yorkpy-Part2

You can download this post as PDF at  IPLT20-yorkpy-part2

You can download all the data used in this post and the previous post at  yorkpyData

1. Functions related to head-to-head confrontations between any 2 IPL teams

The following function can be used to analyze the IPL team performance in a T20 match

  1. getAllMatchesBetweenTeams()
  2. saveAllMatchesBetween2IPLTeams()
  3. teamBatsmenPartnershiOppnAllMatches()
  4. teamBatsmenPartnershipOppnAllMatchesChart()
  5. teamBatsmenVsBowlersOppnAllMatches()
  6. teamBattingScorecardOppnAllMatches()
  7. teamBowlingScorecardOppnAllMatches()
  8. teamBowlingWicketKindOppositionAllMatches()
  9. teamBowlersVsBatsmenOppnAllMatches()
  10. plotWinLossBetweenTeams()
  11. plotWinsByRunOrWickets()
  12. plotWinsbyTossDecision()

All functions relate to the performance of an IPL team in all matches against an opposing IPL team

2. Get data for all T20 matches between 2 teams

We can get all IPL T20 matches between any 2 teams using the function below. The dir parameter should point to the folder which has the IPL T20 csv files of the individual matches (see Pitching yorkpy…short of good length to IPL-Part 1 ). This function creates a data frame of all the IPL T20 matches and and also saves the dataframe as CSV file if save=True. If save=False the dataframe is just returned and not saved.

import pandas as pd
import os
import yorkpy.analytics as yka
#dir1= "C:\\software\\cricket-package\\yorkpyPkg\\yorkpyData\\IPLConverted"
#yka.getAllMatchesBetweenTeams("Kolkata Knight Riders","Delhi Daredevils",dir=dir1,save=True)

3. Save data for all matches between all combination of 2 teams

This can be done locally using the function below. You could use this function to combine all IPL Twenty20 matches between any 2 IPL teams into a single dataframe and save it in the current folder. All the dataframes for all combinations have already been done and are available as CSV files in Github at yorkpyData

import pandas as pd
import os
import yorkpy.analytics as yka
#dir1= "C:\\software\\cricket-package\\yorkpyPkg\\yorkpyData\\IPLConverted"
#yka.saveAllMatchesBetween2IPLTeams(dir1)

Note:In the functions below, I have randomly chosen any 2 IPL teams and analyze how the teams have performed against each other in different areas. You are free to choose any 2 combination of IPL teams for your analysis

4.Team Batsmen partnership in Twenty20 (all matches with opposing IPL team – summary)

The function below computes the highest partnerships between the 2 IPL teams Chennai Superkings and Delhi Daredevils. Any other 2 IPL team could have also been chosen. The summary gives the top 3 batsmen for Delhi Daredevils namely Sehwag, Gambhir and Dinesh Karthik when the report=‘summary’

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Chennai Super Kings-Delhi Daredevils-allMatches.csv")
csk_dd_matches = pd.read_csv(path)
m=yka.teamBatsmenPartnershiOppnAllMatches(csk_dd_matches,'Delhi Daredevils',report="summary")
print(m)
##            batsman  totalPartnershipRuns
## 49        V Sehwag                   233
## 12       G Gambhir                   200
## 21      KD Karthik                   180
## 10       DA Warner                   134
## 4   AB de Villiers                   133

5. Team Batsmen partnership in Twenty20 (all matches with opposing IPL team -detailed)

The function below gives the detailed breakup of partnerships between Deccan Chargers and Mumbai Indians for Deccan Chargers.

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Deccan Chargers-Mumbai Indians-allMatches.csv")
dc_mi_matches = pd.read_csv(path)
theTeam='Deccan Chargers'
m=yka.teamBatsmenPartnershiOppnAllMatches(dc_mi_matches,theTeam,report="detailed", top=4)
print(m)
##          batsman  totalPartnershipRuns      non_striker  partnershipRuns
## 0   AC Gilchrist                   201        A Symonds                0
## 1   AC Gilchrist                   201         HH Gibbs               53
## 2   AC Gilchrist                   201        MD Mishra                0
## 3   AC Gilchrist                   201        RG Sharma               20
## 4   AC Gilchrist                   201    Shahid Afridi                6
## 5   AC Gilchrist                   201         TL Suman                7
## 6   AC Gilchrist                   201       VVS Laxman              115
## 7       S Dhawan                   122         A Mishra                9
## 8       S Dhawan                   122         B Chipli                1
## 9       S Dhawan                   122         CL White                2
## 10      S Dhawan                   122     DT Christian               52
## 11      S Dhawan                   122         IR Jaggi                2
## 12      S Dhawan                   122        JP Duminy                9
## 13      S Dhawan                   122    KC Sangakkara               16
## 14      S Dhawan                   122         PA Patel               22
## 15      S Dhawan                   122          S Sohal                9
## 16     RG Sharma                   103        A Symonds               11
## 17     RG Sharma                   103     AC Gilchrist               18
## 18     RG Sharma                   103         DR Smith                6
## 19     RG Sharma                   103         HH Gibbs                3
## 20     RG Sharma                   103   Jaskaran Singh               15
## 21     RG Sharma                   103        KAJ Roach                4
## 22     RG Sharma                   103        LPC Silva                0
## 23     RG Sharma                   103         TL Suman               14
## 24     RG Sharma                   103  Y Venugopal Rao               32
## 25      HH Gibbs                   102     AC Gilchrist               40
## 26      HH Gibbs                   102         DR Smith               24
## 27      HH Gibbs                   102        MD Mishra               27
## 28      HH Gibbs                   102        RG Sharma                8
## 29      HH Gibbs                   102       VVS Laxman                1
## 30      HH Gibbs                   102  Y Venugopal Rao                2

6. Team Batsmen partnership in Twenty20 – Chart (all matches with opposing IPL team)

The function below plots the partnerships in all matches between 2 IPL teams and plots as chart

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Gujarat Lions-Kings XI Punjab-allMatches.csv")
gl_kxip_matches = pd.read_csv(path)
yka.teamBatsmenPartnershipOppnAllMatchesChart(gl_kxip_matches,'Kings XI Punjab','Gujarat Lions', plot=True, top=4, partnershipRuns=20)

ye6Rze6.png!web

7.Team Batsmen partnership in Twenty20 – Dataframe (all matches with opposing IPL team)

This function does not plot the data but returns the dataframe to the user to plot or manipulate.

Note: Many of the plots include an additional parameters for e.g. plot which is either True or False. The default value is plot=True. When plot=True the plot will be displayed. When plot=False the data frame will be returned to the user. The user can use this to create an interactive charts. The parameter top= specifies the number of top batsmen that need to be included in the chart, and partnershipRuns gives the minimum cutoff runs in partnerships to be considered

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Kolkata Knight Riders-Rising Pune Supergiants-allMatches.csv")
kkr_rps_matches = pd.read_csv(path)
m=yka.teamBatsmenPartnershipOppnAllMatchesChart(kkr_rps_matches,'Rising Pune Supergiants','Kolkata Knight Riders', plot=False, top=5, partnershipRuns=20)
print(m)
##         batsman   non_striker  partnershipRuns
## 0     AM Rahane  F du Plessis               20
## 1     AM Rahane     JA Morkel               16
## 2     AM Rahane   NLTC Perera                6
## 3     AM Rahane     SPD Smith               25
## 4     AM Rahane    UT Khawaja                2
## 5     GJ Bailey     IK Pathan                4
## 6     GJ Bailey     SS Tiwary               28
## 7     GJ Bailey    UT Khawaja                1
## 8      MS Dhoni     IK Pathan                5
## 9      MS Dhoni     JA Morkel                1
## 10     MS Dhoni   NLTC Perera                2
## 11     MS Dhoni      R Ashwin                1
## 12     MS Dhoni      R Bhatia               22
## 13    SPD Smith     AM Rahane               31
## 14  NLTC Perera     AM Rahane               12
## 15  NLTC Perera      MS Dhoni               13

8. Team batsmen versus bowler in Twenty20-Chart (all matches with opposing IPL team)

The plots below provide information on how each of the top batsmen of the IPL teams fared against the opposition bowlers

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Rajasthan Royals-Royal Challengers Bangalore-allMatches.csv")
rr_rcb_matches = pd.read_csv(path)
yka.teamBatsmenVsBowlersOppnAllMatches(rr_rcb_matches,'Rajasthan Royals',"Royal Challengers Bangalore",plot=True,top=3,runsScored=20)

363imef.png!web

9 Team batsmen versus bowler in Twenty20-Dataframe (all matches with opposing IPL team)

This function provides the bowling performance, the number of overs bowled, maidens, runs conceded. wickets taken and economy rate for the IPL match

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Mumbai Indians-Delhi Daredevils-allMatches.csv")
mi_dd_matches = pd.read_csv(path)
m=yka.teamBatsmenVsBowlersOppnAllMatches(mi_dd_matches,'Delhi Daredevils',"Mumbai Indians",plot=False,top=2,runsScored=50)
print(m)
##       batsman           bowler  runsScored
## 0    V Sehwag          A Nehra         6.0
## 1    V Sehwag       AG Murtaza         6.0
## 2    V Sehwag         AM Nayar        14.0
## 3    V Sehwag         CJ McKay        10.0
## 4    V Sehwag     CRD Fernando         9.0
## 5    V Sehwag         DJ Bravo         9.0
## 6    V Sehwag      DJ Thornely         0.0
## 7    V Sehwag         DR Smith        13.0
## 8    V Sehwag      DS Kulkarni        20.0
## 9    V Sehwag  Harbhajan Singh        54.0
## 10   V Sehwag        JJ Bumrah        19.0
## 11   V Sehwag       KA Pollard        37.0
## 12   V Sehwag         MM Patel        27.0
## 13   V Sehwag          PP Ojha         7.0
## 14   V Sehwag         R Shukla         9.0
## 15   V Sehwag      RJ Peterson         7.0
## 16   V Sehwag         RP Singh        28.0
## 17   V Sehwag       SL Malinga        32.0
## 18   V Sehwag       SM Pollock        25.0
## 19   V Sehwag    ST Jayasuriya        29.0
## 20   V Sehwag           Z Khan        14.0
## 21  JP Duminy      CJ Anderson         3.0
## 22  JP Duminy        HH Pandya         7.0
## 23  JP Duminy  Harbhajan Singh        29.0
## 24  JP Duminy        J Suchith         5.0
## 25  JP Duminy        JJ Bumrah        70.0
## 26  JP Duminy       KA Pollard        29.0
## 27  JP Duminy        KH Pandya         8.0
## 28  JP Duminy       M de Lange         6.0
## 29  JP Duminy   MJ McClenaghan        14.0
## 30  JP Duminy           N Rana         1.0
## 31  JP Duminy          PP Ojha        16.0
## 32  JP Duminy    R Vinay Kumar        18.0
## 33  JP Duminy        RG Sharma         3.0
## 34  JP Duminy          S Gopal         8.0
## 35  JP Duminy       SL Malinga         8.0
## 36  JP Duminy       TG Southee         3.0

10. Team batting scorecard(all matches with opposing IPL team)

This function provides the overall scorecard for an IPL team in all matches against another IPL team. In the snippet below the batting scorecard of RCB is show against CSK. Kohli, Gayle and De villiers lead the pack.

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Royal Challengers Bangalore-Chennai Super Kings-allMatches.csv")
rcb_csk_matches = pd.read_csv(path)
scorecard=yka.teamBattingScorecardOppnAllMatches(rcb_csk_matches,'Royal Challengers Bangalore',"Chennai Super Kings")
print(scorecard)
##              batsman  runs  balls  4s  6s          SR
## 5            V Kohli   706    570  51   0  123.859649
## 20          CH Gayle   270    228  12   0  118.421053
## 19    AB de Villiers   241    157  26   0  153.503185
## 6           R Dravid   133    117  18   0  113.675214
## 3          JH Kallis   123    113  21   0  108.849558
## 22        MA Agarwal   120    104  15   0  115.384615
## 2        LRPL Taylor   117    102   5   0  114.705882
## 11        RV Uthappa   115     77   7   0  149.350649
## 21         SS Tiwary    86     88   4   0   97.727273
## 17         MK Pandey    73     72  10   0  101.388889
## 32        KD Karthik    61     58   9   0  105.172414
## 34           D Wiese    51     43   4   0  118.604651
## 33           SN Khan    50     36   5   0  138.888889
## 1           W Jaffer    50     36   5   0  138.888889
## 7            P Kumar    39     25   2   0  156.000000
## 28      Yuvraj Singh    38     33   2   0  115.151515
## 4         MV Boucher    37     33   4   0  112.121212
## 23     LA Pomersbach    31     21   2   0  147.619048
## 8             Z Khan    29     27   3   0  107.407407
## 12      KP Pietersen    23     15   2   0  153.333333
## 38          CL White    21     13   2   0  161.538462
## 26       YV Takawale    19     17   4   0  111.764706
## 31          MS Bisla    17     14   3   0  121.428571
## 14     R Vinay Kumar    17     10   1   0  170.000000
## 25        RR Rossouw    15     13   1   0  115.384615
## 40        AUK Pathan    14      6   2   0  233.333333
## 42   JJ van der Wath    14     11   1   0  127.272727
## 27            VH Zol    13     12   0   0  108.333333
## 30          MA Starc    13     16   1   0   81.250000
## 24      MC Henriques    12      4   3   0  300.000000
## 44          A Mithun    11      8   2   0  137.500000
## 50          PA Patel    10     14   2   0   71.428571
## 36        SP Goswami    10     19   1   0   52.631579
## 0           B Chipli     8     12   1   0   66.666667
## 9            B Akhil     8     12   1   0   66.666667
## 29            S Rana     6      8   0   0   75.000000
## 16  RE van der Merwe     5     12   0   0   41.666667
## 49   KB Arun Karthik     5      5   0   0  100.000000
## 54     Mandeep Singh     4      7   0   0   57.142857
## 37     Misbah-ul-Haq     4      6   0   0   66.666667
## 52      NJ Maddinson     4      7   1   0   57.142857
## 51          AN Ahmed     4      1   1   0  400.000000
## 15          A Kumble     3      6   0   0   50.000000
## 43        DL Vettori     3      4   0   0   75.000000
## 47      DT Christian     2      2   0   0  100.000000
## 45   J Syed Mohammad     2      3   0   0   66.666667
## 35          HV Patel     2      5   0   0   40.000000
## 41         CA Pujara     2      6   0   0   33.333333
## 10          DW Steyn     1      5   0   0   20.000000
## 18        EJG Morgan     1      4   0   0   25.000000
## 46        RR Bhatkal     0      2   0   0    0.000000
## 48         R Rampaul     0      6   0   0    0.000000
## 13         R Bishnoi     0      1   0   0    0.000000
## 39        TM Dilshan     0      1   0   0    0.000000
## 53     Iqbal Abdulla     0      3   0   0    0.000000
## 55         S Aravind     0      1   0   0    0.000000

11.Team Bowling scorecard (all matches with opposing IPL team)

The output below gives the performance of Rajasthan Royals bowlers against Kolkata Knight Riders in all matches between the 2 IPL teams.

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Kolkata Knight Riders-Rajasthan Royals-allMatches.csv")
rcb_csk_matches = pd.read_csv(path)
scorecard=yka.teamBowlingScorecardOppnAllMatches(rcb_csk_matches,'Rajasthan Royals',"Kolkata Knight Riders")
print(scorecard)
##               bowler  overs  runs  maidens  wicket   econrate
## 31   Shakib Al Hasan     25   153        0       9   6.120000
## 12          I Sharma     15   118        0       6   7.866667
## 33          Umar Gul      8    61        0       6   7.625000
## 29         SP Narine     24   155        0       6   6.458333
## 1           AB Dinda     20   126        0       6   6.300000
## 23     R Vinay Kumar      8    72        0       5   9.000000
## 22          R Bhatia     15   104        0       5   6.933333
## 0         AB Agarkar     12   105        0       4   8.750000
## 17         LR Shukla     12    87        0       4   7.250000
## 6              B Lee     15    90        0       4   6.000000
## 3         AD Russell      7    59        0       4   8.428571
## 34         YK Pathan      8    61        0       4   7.625000
## 14        JD Unadkat      4    26        0       3   6.500000
## 15         JH Kallis     20   149        0       3   7.450000
## 16          L Balaji     11    73        0       3   6.636364
## 27           SE Bond      8    52        1       3   6.500000
## 10     CK Langeveldt      4    15        0       3   3.750000
## 13     Iqbal Abdulla     10    70        0       3   7.000000
## 28   SMSM Senanayake      4    26        0       2   6.500000
## 7         BAW Mendis      4    19        0       2   4.750000
## 18          M Kartik      8    56        0       2   7.000000
## 4      Anureet Singh      4    35        0       2   8.750000
## 32          UT Yadav      7    67        0       2   9.571429
## 30         SS Sarkar      3    15        0       1   5.000000
## 26        SC Ganguly      6    61        0       1  10.166667
## 5      Azhar Mahmood      3    41        0       1  13.666667
## 19          M Morkel      8    78        0       1   9.750000
## 11         DJ Hussey      2    26        0       0  13.000000
## 2         AD Mathews      3    33        0       0  11.000000
## 8           BJ Hodge      2    34        0       0  17.000000
## 25          S Narwal      2    17        0       0   8.500000
## 24  RN ten Doeschate      2    14        0       0   7.000000
## 21         PP Chawla      4    39        0       0   9.750000
## 20    Mohammed Shami      3    26        0       0   8.666667
## 9           CH Gayle      4    20        0       0   5.000000

12. Team Bowling wicket kind -Chart (all matches with opposing IPL team)

The functions compute and display the kind of wickets taken(bowled, caught, lbw etc) by an IPL team in all matches against another IPL team

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Chennai Super Kings-Rajasthan Royals-allMatches.csv")
csk_rr_matches = pd.read_csv(path)
yka.teamBowlingWicketKindOppositionAllMatches(csk_rr_matches,'Chennai Super Kings','Rajasthan Royals',plot=True,top=5,wickets=1)

Z7RZZjZ.png!web

13. Team Bowling wicket kind -Dataframe (all matches with opposing IPL team)

This gives the type of wickets taken

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Delhi Daredevils-Pune Warriors-allMatches.csv")
dd_pw_matches = pd.read_csv(path)
m=yka.teamBowlingWicketKindOppositionAllMatches(dd_pw_matches,'Pune Warriors','Delhi Daredevils',plot=False,top=4,wickets=1)
print(m)
##       bowler    kind  wickets
## 0  IK Pathan  bowled        1
## 1  IK Pathan  caught        3
## 2   M Morkel  bowled        1
## 3   M Morkel  caught        3
## 4   S Nadeem  bowled        1
## 5   S Nadeem  caught        2
## 6   UT Yadav  caught        3

14 Team Bowler vs Batman -Plot (all matches with opposing IPL team)

The function below gives the performance of bowlers in all matches against another IPL team.

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Sunrisers Hyderabad-Kolkata Knight Riders-allMatches.csv")
srh_kkr_matches = pd.read_csv(path)
yka.teamBowlersVsBatsmenOppnAllMatches(srh_kkr_matches,'Sunrisers Hyderabad','Kolkata Knight Riders',plot=True,top=5,runsConceded=10)

iQraEjb.png!web

15 Team Bowler vs Batman – Dataframe (all matches with opposing IPL team)

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Royal Challengers Bangalore-Kings XI Punjab-allMatches.csv")
srh_kkr_matches = pd.read_csv(path)
m=yka.teamBowlersVsBatsmenOppnAllMatches(srh_kkr_matches,'Royal Challengers Bangalore','Kings XI Punjab',plot=False,top=1,runsConceded=30)
print(m)
##        bowler           batsman  runsConceded
## 0   PP Chawla          A Kumble             1
## 1   PP Chawla          A Mithun             1
## 2   PP Chawla       AB McDonald             3
## 3   PP Chawla    AB de Villiers            29
## 4   PP Chawla         CA Pujara            13
## 5   PP Chawla          CH Gayle            62
## 6   PP Chawla     CK Langeveldt             1
## 7   PP Chawla          CL White             3
## 8   PP Chawla        DL Vettori             1
## 9   PP Chawla          DT Patil             4
## 10  PP Chawla         JH Kallis            17
## 11  PP Chawla   JJ van der Wath             1
## 12  PP Chawla   KB Arun Karthik             4
## 13  PP Chawla      KP Pietersen            14
## 14  PP Chawla       LRPL Taylor             6
## 15  PP Chawla            M Kaif             2
## 16  PP Chawla         MK Pandey            10
## 17  PP Chawla        MV Boucher             9
## 18  PP Chawla     Misbah-ul-Haq             0
## 19  PP Chawla           P Kumar             0
## 20  PP Chawla          R Dravid            28
## 21  PP Chawla  RE van der Merwe             7
## 22  PP Chawla        RV Uthappa            19
## 23  PP Chawla         SS Tiwary             6
## 24  PP Chawla           V Kohli            56
## 25  PP Chawla            Z Khan             0

16 Team Wins and Losses (all matches with opposing IPL team)

The function below computes and plot the number of wins and losses in a head-on confrontation between 2 IPL teams

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Chennai Super Kings-Delhi Daredevils-allMatches.csv")
csk_dd_matches = pd.read_csv(path)
yka.plotWinLossBetweenTeams(csk_dd_matches,'Chennai Super Kings','Delhi Daredevils')

6v263mQ.png!web

17 Team Wins by win type (all matches with opposing IPL team)

This function shows how the win happened whether by runs or by wickets

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Chennai Super Kings-Delhi Daredevils-allMatches.csv")
csk_dd_matches = pd.read_csv(path)
yka.plotWinsByRunOrWickets(csk_dd_matches,'Chennai Super Kings')

bu6j6bI.png!web

18 Team Wins by toss decision-field (all matches with opposing IPL team)

This show how Rajasthan Royals fared when it chose to field on winning the toss

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Rajasthan Royals-Kings XI Punjab-allMatches.csv")
rr_kxip_matches = pd.read_csv(path)
yka.plotWinsbyTossDecision(rr_kxip_matches,'Rajasthan Royals',tossDecision='field')

JZfeEzb.png!web

18 Team Wins by toss decision-bat (all matches with opposing IPL team)

This plot shows how Mumbai Indians fared when it chose to bat on winning the toss

import pandas as pd
import os
import yorkpy.analytics as yka
dir1= "C:\\software\\cricket-package\\yorkpyIPLData\\data1"
path=os.path.join(dir1,"Mumbai Indians-Royal Challengers Bangalore-allMatches.csv")
mi_rcb_matches = pd.read_csv(path)
yka.plotWinsbyTossDecision(mi_rcb_matches,'Mumbai Indians',tossDecision='bat')

7zYZzmr.png!web

Feel free to clone/download the code from Github yorkpy


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK