INDIAN PREMIER LEAGUE(2008–2019) DATA-ANALYSIS WITH PANDAS AND MATPLOTLIB AND SEABORN

Darshakrakholiya
7 min readSep 19, 2020

Indian Premier League is the india best carnival or best festival.India in probably always played matches on march to jun but that time covid-19 pandemic due to ipl going to play in dubai and date is 19-september to 10-november.

Here We are discuss about a indian premier league(ipl) data of the 2008 to 2019.we are perform exploratory Analysis & Visualization on indian premire league dataset which we find or you find on https://kaggle.com

In this project we are perform some analysis process means with python using pandas and numpy using some mathematical operations and better understanding for use matplotlib and seaborn using visualize some graph and learn some new thing.

First of you defined Project Name

Data Preparation and Cleaning

First of all we are import and install mandatory module any libraries

  • Install pandas & Import pandas
  • Install matplotlib & Import matplotlib
  • Install seaborn & Import seaborn

Now we are read the data flies now that we gather or find on the kaggle dataset using pandas

now display the dataset content

Now we find the how many rows and column in the dataset

using .shape method

Data from the file is read and stored in a DataFrame object — one of the core data structures in Pandas for storing and working with tabular data. We typically use the _df suffix in the variable names for dataframes.

It appears that each column contains values of a specific data type. For the numeric columns, you can view the some statistical information like mean, standard deviation, minimum/maximum values and number of non-empty values using the .describe method.

The columns property contains the list of columns within the data frame.

you can retrieve a specific value with a series using the indexing notation []. like array

stead of using the indexing notation [], Pandas also allows accessing columns as properties of the data frame using the . notation. However, this method only works for columns whose names do not contain spaces or special chracters.

To view the first or last few rows of data, we can use the .head and .tail methods.

  • first_valid_index — Finding the first non-empty index in a series

The .sample method can be used to retrieve a random sample of rows from the data frame

Here some Teams name are change with the time of the season that’s why change the name of of team

  • Rising Pune Supergiants : Rising Pune Supergiant
  • Delhi Daredevils : Delhi Capitals

Here Some city data is Nan for that Nan position on Put values as “Mumbai”.

Sorting rows using column values

  • The rows can also be sorted by a specific column using .sort_values. Let’s sort to identify the days with the highest number of cases, then chain it with the head method to get the 10 days with the most cases.

Details Display between location of 256 to 300.

The date column might come in handy here, as Pandas provides many utilities for working with dates.

You can see that it now has the datatype datetime64. We can now extract different parts of the data into separate columns, using the DatetimeIndex class

Let’s Find the Season 2017 in How many matches Played?

Here We Find Season 2017 in how many matches played for perform some numerical task means .count and year matches with 2017 id with then display

  • let’s find in season 2017 how many matches palyed on sunday?

In season 2017 in how many matches played that find above then now we find how many matches in season 2017 in played on sunday that’s why comapre weekday with number 6 and then count number of matches played on sunday

Display it!

How many matches win the Chennai Super Kings starting to till now?

Now talking about most loveable team in ipl is chennai super kings

on csk team 2008 to 2019 how many matches won that’s task for perform winner cloumns compare with team name and count id and

display it!

Exploratory Analysis and Visualization

In this Section We are explore the Over understanding with some chart and graph with visualization and also contenting sum numpy using compute some analysis

first we import some visulaization libraries for visualize the graph

  • import matplotlib.pyplot
  • import seaborn

Then We perform some task on ipl dataset then understand graph What you wants to say

  • Total played matches season Wise
  • Total Winning matches each team till 2019
  • Compare total played vs total winning
  • install libraries and import it!

.unique method use for in the columns or row in unique values

Here count total numbers of matches till 2019.

Total played matches season wise

Here We find season wise total matches of ipl and here season and id = Total number of matches

Here you can see number of team to with number of matches win

Now We plot first graph for each team winng matches per each team

Here we perform task

  • Set plot style
  • Plot figure size
  • Set plot title
  • Now plot graph with seaborn in barplot

Now plot graph for total palyed matches by each team

Here we perform task

  • Plot figure size
  • Set plot title
  • Set x axis Label
  • Set Y axis Label
  • perform some .groupby method
  • set xticks or yticks for naming convenience
  • Now plot graph with matplotlib in bar

Compare Total Played Matches vs Winning Matches vs Win Rate

Here we perform multiple task in one graph

  • (1). Total played Matches by each team
  • (2). Winng Matches by each team
  • (3). Winrate of each team

Here Display

  • Team
  • total_matches
  • won_the_matches
  • win_rate

Better Understanding for use Visualization with seaborn and matplotlib

Here we perform task

  • Plot figure size
  • Set plot title
  • Set x axis Label
  • Set Y axis Label
  • Set xticks or yticks for naming convenience
  • Now plot graph with matplotlib in plot with some fmt format
  • Now plot graph with matplotlib in bar graph with opacity
  • In graph legend use for which values for which team

Here We perform some extra Visualization graph that’s called distplot with figure size and title

Here we perform task for Winrate of Each Team

  • Plot figure size
  • Set plot title
  • Now plot graph with matplotlib in bar graph with opacity

Here we perform task

  • Plot figure size
  • Set plot title
  • Set x axis Label
  • Set Y axis Label
  • Set xticks or yticks for naming convenience
  • Now plot graph with seasborn in scatterplot with hue and shape

Asking and Answering Questions

  • (1) How many matches in ipl till now to Won the toss and as well as Match Winner?
  • (2) Who are the top 15 players in ipl is most of the time get Man of Match Awards?
  • (3)Best Rivalry in the ipl RCB vs KXIP who won most of the matches on between?
  • (4)What is the choice of each team after winning the toss?
  • (5)City Wise Find How many Matches hosted each city to 2008 to till 2019?

(1) How many matches in ipl till now to Won the toss and as well as Match Winner?

2) Who are the top 15 players in ipl is most of the time get Man of Match Awards?

Here some top batsman who winnning most man of the match awards in 2008 to 2019 ipl.

Here we perform task

  • numpy libraries for mathematical operation
  • Plot figure size
  • Set plot title with fontweight
  • Set xticks for naming convenience with rotation = 90
  • Set yticks with np.arange method
  • Set x axis Label with fontweight
  • Set Y axis Label with fontweight
  • Now plot graph with seaborn in barplot

(3)Best Rivalry in the ipl RCB vs KXIP who won most of the matches on between?

now here perform groupby method then display both of team head to head win same matches till yet.

Here we perform task

  • numpy libraries for mathematical operation
  • Plot figure size
  • Set plot title with fontweight
  • Set yticks with np.arange method
  • Set x axis Label with fontweight
  • Set Y axis Label with fontweight
  • Now plot graph with seaborn in barplot

(4)What is the choice of each team after winning the toss?

Here we perform task

  • Perform .groupby method with lambda and .apply method to rest_index()
  • For heatmap in pivot is use full methos
  • Plot figure size
  • Set plot title with fontweight
  • Two values for create subplots
  • Heatmap graph in seaborn with plot heatmap with annot,fmt format
  • In heatmap in xaxis on set position

(5)City Wise Find How many Matches hosted each city to 2008 to till 2019?

Here display city wise hosted how many matches 2008 to 2019 yet.

Here we perform task

  • Plot figure size
  • Set plot title with fontweight and fontsize
  • Set x axis Label with fontweight and fontsize
  • Set Y axis Label with fontweight and fontsize
  • Set xticks with rotation = 90 ,fontweight and fontsize
  • Now plot graph with seaborn in barplot

Here display the Most sucessful ipl yet in ipl with highest number of time winning ipl title.

Inferences and Conclusion

  • In this Project We are consider Ipl dataset on analysis using python with pandas and numpy and perform some mathematical operation and visulatize the graph with matplotlib and seaborn
  • Also i learning lots of new things in this course and i choose my carrer path with that course and i also learn in that course with https://jovian.ml/ and also forum community lot’s of support to the community.
  • In this course first we introduce with basic python to working with os and file.
  • Next lesson in we discuss of python in numpy libraries and also work with lot’s of new operation
  • Then nest lesson discuss pandas libraries and perform some task with some dataset
  • Then better understaning for Perform exploratory Analysis & Visualization with matplotlib and seaborn
  • And also with the lesson do some assignment through the also learn other thing.

References and Future Work

Special ThankFul of https://jovian.ml/ and https://jovian.ml/aakashns

Really appreciate

Thank you for Read my First Blog Post

--

--