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
10 changes: 10 additions & 0 deletions q01_plot_deliveries_by_team/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# %load q01_plot_deliveries_by_team/build.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.switch_backend('agg')


ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)


# Solution
def plot_deliveries_by_team(ipl_df=ipl_df):
ipl_df['batting_team'].value_counts().plot.bar()
plot_deliveries_by_team()





8 changes: 8 additions & 0 deletions q02_plot_matches_by_team/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# %load q02_plot_matches_by_team/build.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.switch_backend('agg')
ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)

def plot_matches_by_team():
ipl_df.groupby('batting_team').agg({'match_code': pd.Series.nunique}).plot.bar()

plot_matches_by_team()

# Solution



14 changes: 14 additions & 0 deletions q03_plot_innings_runs_histogram/build.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %load q03_plot_innings_runs_histogram/build.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -6,3 +7,16 @@


# Solution
def plot_innings_runs_histogram():
inning_wise_runs = ipl_df.groupby(['match_code', 'inning'])['runs'].sum()
first_inning_runs = inning_wise_runs[:,1]
second_inning_runs = inning_wise_runs[:,2]
fig, axs = plt.subplots(1, 2, sharey=True, tight_layout=True)

axs[0].hist(first_inning_runs)
axs[1].hist(second_inning_runs)

return



11 changes: 11 additions & 0 deletions q04_plot_runs_by_balls/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
# %load q04_plot_runs_by_balls/build.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
plt.switch_backend('agg')
ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)

def plot_runs_by_balls():
balls_played_by_player = ipl_df.groupby(['match_code','batsman'])['delivery'].agg('count')
runs_made_by_player = ipl_df.groupby(['match_code','batsman'])['runs'].agg('sum')
plt.scatter(balls_played_by_player, runs_made_by_player)

return

# Solution