Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions q01_plot_deliveries_by_team/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@


# Solution
def plot_deliveries_by_team():
team_delivery = ipl_df.pivot_table('delivery', aggfunc = np.count_nonzero, index ='batting_team')

team_delivery.plot(kind = 'bar')
plt.show()
7 changes: 7 additions & 0 deletions q02_plot_matches_by_team/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@


# Solution
def plot_matches_by_team():
ipl_df['count'] = 1
data = ipl_df[['batting_team','match_code','count']]
matches = data.groupby(['batting_team','match_code']).agg(np.unique)
teams = matches['count'].groupby(['batting_team']).sum()
bar_plot = teams.plot(kind = 'bar')
plt.show()
10 changes: 10 additions & 0 deletions q03_plot_innings_runs_histogram/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@


# Solution
def plot_innings_runs_histogram():
a = ipl_df.groupby(by=['match_code','inning'],as_index=0)['runs'].count()
b= a[a['inning']==1]#['runs']
c= a[a['inning']==2]#['runs']
#x =pd.DataFrame(columns=[b,c])
plt.subplot(1,2,1)
b['runs'].hist()#.groupby(by='runs').count()#['inning'].hist()
plt.subplot(1,2,2)
c['runs'].hist()
plt.show()
7 changes: 7 additions & 0 deletions q04_plot_runs_by_balls/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@


# Solution
def plot_runs_by_balls():
data = ipl_df[['batsman','delivery','runs']]
batsman = data.groupby(['batsman'])
balls = batsman['delivery'].count()
runs = batsman['runs'].sum()
plt.scatter(balls,runs)
plt.show()