Exploratory Data Analysis of IPL Matches-Part I
By: Bipin P.
Tags: Data Analysis, Indian Premier League, Exploratory Data Analysis, Data Science, Ipl

The dataset consist of data about IPL matches played from the year 2008 to 2019. IPL is a professional Twenty20 cricket league founded by the Board of Control for Cricket in India (BCCI) in 2008. The league has 8 teams representing 8 different Indian cities or states. It enjoys tremendous popularity and the brand value of the IPL in 2019 was estimated to be ₹475 billion (US$6.7 billion). So let’s analyze IPL through stats.

Objectives:

To find the team that won the most number of matches in a season.

To find the team that lost the most number of matches in a season.

Does winning toss increases the chances of victory.

To find the player with the most player of the match awards.

To find the city that hosted the maximum number of IPL matches.

To find the most winning team for each season.

To find the on-field umpire with the maximum number of IPL matches.

To find the biggest victories in IPL while defending a total and while chasing a total.

To have a detailed understanding of Exploratory Data Analysis(EDA), I recommend you to visit my blog:

Data Preparation and Cleaning

Let’s start by reading the csv file to Pandas DataFrame.

import pandas as pd

ipl_matches_df = pd.read_csv('matches.csv')

So there are 756 rows and 18 columns. 756 rows imply that there were 756 IPL matches held between 2008 and 2019.

Observations:

The following inferences can be made from the describe() method:

The .csv file has data of IPL matches starting from the season 2008 to 2019.

The biggest margin of victory for the team batting first(win_by_runs) is 146 runs .

. The biggest victory of the team batting second(win_by_wickets) is by 10 wickets .

. 75% of the victorious teams that bat first won by a margin of 19 runs .

. 75% of the victorious teams that bat second won by a margin of 6 wickets .

. There were 756 IPL matches hosted from 2008 to 2019.

Let’s view the unique values of each column to help us understand the dataset better.

The dataset has 18 columns. Let’s get acquainted with the columns.

id : The IPL match id.

: The IPL match id. season : The IPL season

: The IPL season city : The city where the IPL match was held.

: The city where the IPL match was held. date : The date on which the match was held.

: The date on which the match was held. team1 : One of the teams of the IPL match

: One of the teams of the IPL match team2 : The other team of the IPL match

: The other team of the IPL match toss_winner : The team that won the toss

: The team that won the toss toss_decision : The decision taken by the team that won the toss to ‘bat’ or ‘field’

: The decision taken by the team that won the toss to ‘bat’ or ‘field’ result : The result(‘normal’, ‘tie’, ‘no result’) of the match.

: The result(‘normal’, ‘tie’, ‘no result’) of the match. dl_applied : (1 or 0)indicates whether the Duckworth-Lewis rule was applied or not.

: (1 or 0)indicates whether the Duckworth-Lewis rule was applied or not. winner : The winner of the match.

: The winner of the match. win_by_runs : Provides the runs by which the team batting first won

: Provides the runs by which the team batting first won win_by_runs : Provides the number of wickets by which the team batting second won.

: Provides the number of wickets by which the team batting second won. player_of_match : The outstanding player of the match.

: The outstanding player of the match. venue : The venue where the match was hosted.

: The venue where the match was hosted. umpire1 : One of the two on-field umpires who officiate the match.

: One of the two on-field umpires who officiate the match. umpire2 : One of the two on-field umpires who officiate the match.

: One of the two on-field umpires who officiate the match. umpire3: The off-field umpire who officiates the match

A mere glance of the DataFrame through its columns indicates the presence of NaN values in the ‘umpire3’ column. Let’s see the count of NaN values in the column.

It’s imperative to know the count of NaN values for each column before we proceed further.

The column ‘umpire3’ has a significant number of NaN values. As the off-field umpire parameter is insignificant, we can drop this column. The other columns that have Nan values are of type object(Pandas equivalent of Python String data type) and are very few in number(<=7).

ipl_matches_df = ipl_matches_df.drop(columns=['umpire3'], axis=1)

Exploratory Analysis and Visualization

Now that our data set has been cleaned up, it’s time to do the in-depth analysis and visualization.

Let’s begin by importing matplotlib.pyplot and seaborn .

import seaborn as sns

import matplotlib

import matplotlib.pyplot as plt

%matplotlib inline sns.color_palette("Paired")

matplotlib.rcParams['font.size'] = 14

matplotlib.rcParams['figure.figsize'] = (12, 8)

matplotlib.rcParams['figure.facecolor'] = '#00000000'

To know more about matplotlib.rcParams, kindly visit my blog:

The team with the most number of wins per season.

Each IPL season has a fair share of excitement and adulation. No team other than Chennai Super Kings(in 2010 and 2011) was able to win the IPL trophy in succession. That is a testimony to the unpredictability of IPL.

Let’s analyze the team with the most wins in each season.

The number of wins is a discrete value. Hence, we will plot a bar chart(barplot in Seaborn).

From the barplot, we can easily make inferences regarding the year in which a particular team has scored the maximum wins(and also the number of wins).

Observations:

Mumbai Indians has secured the most wins in four seasons(2010, 2013, 2017, and 2019).

The venue that hosted the maximum number of matches

Observations:

Eden Gardens has hosted the maximum number of IPL matches followed by Wankhede Stadium and M Chinnaswamy Stadium .

. Till 2019, IPL matches were hosted by 40 venues.

The most successful IPL team

In a game of sports, every team competes for victory. Hence, the team that has registered the most number of victories is the most successful.

Observations:

Mumbai Indians is the most successful team(as they have won the maximum number of IPL matches -109) followed by Chennai Super Kings and Kolkata Knight Riders.

Most Valuable Player

Winning matters the most in a competitive league match. If a player makes the most significant contribution to his team’s victory, then he’s chosen as the player_of_match. The player who has won the player_of_match title on most occasions is the most valuable player.

Observations:

Cris Gayle is the player who won the most player of the match awards and hence is the most valuable player .

. Six Indian players have figured in the top ten IPL players list.

The team that won the most number of toss

Observations:

Mumbai Indians has won the most toss(till 2019) in IPL history .

. All the top teams in IPL are successful in winning the toss as well.

Asking and Answering Questions

Let’s try to find answers to the questions that will linger in an IPL fan’s mind. In Part I, we are dealing with some very basic questions. In Part II, we will delve deeper.

Q1: Does the presence of the most valuable players in a team ensures the IPL trophy?

We have figured out the top ten players of IPL using the ‘Player of the Match’ title as the yardstick. It is interesting to note that the top two players — Chris Gayle and AB de Villers have never won an IPL. Of the top ten players, 6 players(RG Sharma, MS Dhoni, DA Warner, SR Watson, SK Raina, and G Gambhir) have won the IPL. It exemplifies the importance of the presence of the most valuable player(s) in a team.

Q2: Which umpire has officiated the most number of IPL matches on-field?

S. Ravi(Sundaram Ravi) has officiated the most number of IPL matches on-field, followed by former Sri Lankan international cricketer HDPK Dharmasena.

Q3: Which team is the most successful team in IPL?

Nothing succeeds like success. In a game of cricket, winning is everything. We have narrowed down on the list of teams that made the most number of wins in each season. The DataFrame win_per_season_df gives the required information. Mumbai Indians has secured the most wins in four seasons(2010, 2013, 2017, and 2019). Mumbai Indians won the IPL trophy in 2013, 2015, 2017, and 2019.

Mumbai Indians secured the most number of wins(109) in IPL, followed by Chennai Super Kings.

Of all the IPL matches played till 2019, Mumbai Indians has emerged victorious in the most number of games. They have secured most wins in four seasons and have won four IPL trophies so far. Hence Mumbai Indians is the most successful team in IPL.

Q4: Which city has hosted the maximum number of IPL matches?

The city of Mumbai has hosted the maximum number of IPL matches.

Q5: Does winning the toss has any advantage?

The probability of winning when the team had won the toss is 52%. So winning toss gives a slight edge over the opponent. However, it would be naive to term winning the toss as a greater advantage as there were 363 instances when the team losing the toss has won the game.

Q6: What are the major victories in IPL? Is it better to defend or chase in IPL?

Of the 756 IPL matches played from 2008 to 2019, 419 matches were won chasing the target . Hence, more victories were registered by teams chasing a total(batting second) than defending the total.

. When defending a total, the biggest victory was by 146 runs. Let’s find out that particular match.

The greatest victory in IPL on defending a total is for Mumbai Indians when they defeated Delhi Daredevils by 146 runs on 06 May 2017 at Feroz Shah Kotla stadium, Delhi.

Of the 756 IPL matches played from 2008 to 2019, 350 matches were won defending the total .

. When chasing a target, the biggest victory was by 10 wickets(without losing any wickets). There were 11 such instances and we can find the details about those matches by the following code snippet:

Inferences and Conclusion

Let’s summarize the important observations we made during Exploratory Data Analysis: