Skip to content

Commit Live PR #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
12 changes: 11 additions & 1 deletion q01_plot_deliveries_by_team/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,15 @@

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

def plot_deliveries_by_team():
count_deliveries = ipl_df.groupby(['batting_team']).agg('count')['delivery']
count_deliveries.plot(kind = 'bar')

plt.show();



plot_deliveries_by_team()



# Solution
10 changes: 9 additions & 1 deletion q02_plot_matches_by_team/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
plt.switch_backend('agg')
ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)

def plot_matches_by_team():
count_matches = ipl_df.groupby(['batting_team']).agg('nunique')['match_code']
count_matches.plot(kind = 'bar')
plt.show();

plot_matches_by_team()




# Solution
8 changes: 7 additions & 1 deletion q03_plot_innings_runs_histogram/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
plt.switch_backend('agg')
ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)

def plot_innings_runs_histogram():
f1_match = ipl_df.groupby(['match_code','inning']).agg('sum')['total']
f1_match.plot(kind= 'hist', subplots= True)
plt.show();

plot_innings_runs_histogram()


# Solution
13 changes: 12 additions & 1 deletion q04_plot_runs_by_balls/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,16 @@
plt.switch_backend('agg')
ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)

def plot_runs_by_balls():
runs_scored = pd.DataFrame(ipl_df.groupby(['match_code', 'batsman']).agg('sum')['runs'])
balls_played = pd.DataFrame(ipl_df.groupby(['match_code', 'batsman']).agg('count')['delivery'])
playedscored = runs_scored.join(balls_played)
plt.scatter(playedscored['runs'], playedscored['delivery'])
plt.show();



plot_runs_by_balls()



# Solution