Skip to content
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Done
  • Loading branch information
SiddharthPant committed Oct 27, 2017
commit b55e1fe3cc2effe1044603cd5fe9ddeac426e583
11 changes: 10 additions & 1 deletion q03_plot_innings_runs_histogram/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
ipl_df = pd.read_csv('data/ipl_dataset.csv', index_col=None)


# Solution
# Solution
def plot_innings_runs_histogram():
match_inning_runs = ipl_df.groupby(by=['match_code', 'inning']).sum()[['runs']]
inning1_df = match_inning_runs.loc[match_inning_runs.index.get_level_values(1) == 1]
inning2_df = match_inning_runs.loc[match_inning_runs.index.get_level_values(1) == 2]
inning1_runs, inning2_runs = inning1_df['runs'], inning2_df['runs']
fig, axes = plt.subplots(nrows=1, ncols=2)
axes[0].hist(inning1_runs, bins=30)
axes[1].hist(inning2_runs, bins=30)
plt.show()