Jovian
⭐️
Sign In
In [42]:
import pandas as pd
import numpy as np
players=pd.read_excel("C:\\Users\\debje\\Desktop\\PYTHON\\EDA\\IPL Data\\Player.xlsx")
ball=pd.read_excel("C:\\Users\\debje\\Desktop\\PYTHON\\EDA\\IPL Data\\Ball_by_Ball.xlsx")
match=pd.read_excel("C:\\Users\\debje\\Desktop\\PYTHON\\EDA\\IPL Data\\Match.xlsx")
team=pd.read_excel("C:\\Users\\debje\\Desktop\\PYTHON\\EDA\\IPL Data\\Team.xlsx")
season=pd.read_excel("C:\\Users\\debje\\Desktop\\PYTHON\\EDA\\IPL Data\\Season.xlsx")
player_match=pd.read_excel("C:\\Users\\debje\\Desktop\\PYTHON\\EDA\\IPL Data\\Player_Match.xlsx")
In [43]:
ball.dtypes
Out[43]:
Match_Id                     int64
Season_Id                    int64
Innings_Id                   int64
Over_Id                      int64
Ball_Id                      int64
Team_Batting_Id              int64
Team_Bowling_Id              int64
Striker_Id                   int64
Striker_Batting_Position     int64
Non_Striker_Id               int64
Bowler_Id                    int64
Batsman_Scored               int64
Extra_Type                  object
Extra_Runs                  object
Player_dissimal_Id          object
Dissimal_Type               object
Fielder_Id                  object
dtype: object
In [44]:
cols1 = [cols1 for cols1 in ball.columns if (cols1!= "Batsman_Scored") and (cols1!="Extra_Runs")]

ball[cols1]= ball[cols1].apply(lambda x: x.astype("category"))
In [45]:
ball.dtypes
Out[45]:
Match_Id                    category
Season_Id                   category
Innings_Id                  category
Over_Id                     category
Ball_Id                     category
Team_Batting_Id             category
Team_Bowling_Id             category
Striker_Id                  category
Striker_Batting_Position    category
Non_Striker_Id              category
Bowler_Id                   category
Batsman_Scored                 int64
Extra_Type                  category
Extra_Runs                    object
Player_dissimal_Id          category
Dissimal_Type               category
Fielder_Id                  category
dtype: object
In [113]:
import matplotlib.pyplot as plt

run_by_innings=ball.pivot_table(index="Innings_Id" ,values="Batsman_Scored", aggfunc=np.sum).reset_index()
final2=pd.DataFrame()
first=run_by_innings[(run_by_innings["Innings_Id"] == 1) | (run_by_innings["Innings_Id"] == 3)]["Batsman_Scored"].sum()
second=run_by_innings[(run_by_innings["Innings_Id"] == 2) | (run_by_innings["Innings_Id"] == 4)]["Batsman_Scored"].sum()

innings=["first_innings","second_innings"]
runs= [first,second]
final2["Innings"]=innings
final2["Runs"]=runs
final2.set_index("Innings",inplace=True)
final2.plot(kind="bar",use_index="Innings")
plt.xticks(rotation=45)
plt.ylabel("Runs")
plt.show()
Notebook Image
In [114]:
match
Out[114]:
In [123]:
# Toss to fiel or bat

toss_decision= match.groupby("Toss_Decision")["Match_Id"].size().reset_index()
toss_decision.rename(columns={"Match_Id": "no. of matches"},inplace=True)
toss_decision
Out[123]:
In [153]:
plt.pie(x=toss_decision["no. of matches"],labels=toss_decision["Toss_Decision"],explode=(0,0.09),autopct="%.1f%%")
plt.show
Out[153]:
<function matplotlib.pyplot.show(*args, **kw)>
Notebook Image
In [164]:
plt.pie(x=toss_decision["no. of matches"],labels=toss_decision["Toss_Decision"],explode=(0,0.09),autopct="%.1f%%")
center_circle=plt.Circle((0,0),0.50,fc="white")
fig=plt.gcf()
fig.gca().add_artist(center_circle)
plt.axis("equal")
plt.show()
Notebook Image
In [165]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: