Skip to content

Commit Live PR #180

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
22 changes: 18 additions & 4 deletions q01_plot_deliveries_by_team/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
#%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')
from matplotlib import pyplot as plt

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

# gr=ipl_df.groupby('batting_team').delivery.agg('count')

# plt.bar(gr.index,gr,title='Bar graph of \n Batting team vs count of deliveries ')
# plt.show()
def plot_deliveries_by_team():
ipl_df.groupby('batting_team').delivery.agg('count').plot(kind='bar',title='Batting team vs count of deliveries ')
plt.xlabel=('batsman')
plt.ylabel=('runs')
plt.show()

plot_deliveries_by_team()


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


# Solution
23 changes: 19 additions & 4 deletions q02_plot_matches_by_team/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
#%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)

from matplotlib import pyplot as plt

ifl_df=pd.read_csv('./data/ipl_dataset.csv')

def plot_matches_by_team():
gr=ifl_df.groupby('batting_team')['match_code'].nunique()
gr.plot(kind='bar',title=' total number of matches played by each team')

plt.xlabel('batsman')
plt.ylabel('matches played')

plt.show()

plot_matches_by_team()




# Solution
24 changes: 19 additions & 5 deletions q03_plot_innings_runs_histogram/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
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)
import pandas as pd
from matplotlib import pyplot as plt

ifl_df=pd.read_csv('./data/ipl_dataset.csv')

def plot_innings_runs_histogram():

gr=ifl_df.groupby(['match_code','inning'])['runs'].sum()
#gr[1::2]

fig = plt.figure()
ax = fig.add_subplot(121)
gr[1::2].plot(kind='hist',title=' total number of runs inning 1')
ax = fig.add_subplot(122)
gr[2::2].plot(kind='hist',title=' total number of runs inning 2')

plt.show()

plot_innings_runs_histogram()


# Solution
29 changes: 25 additions & 4 deletions q04_plot_runs_by_balls/build.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@
#%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)
from matplotlib import pyplot as plt

ifl_df=pd.read_csv('./data/ipl_dataset.csv')
# ifl_df.columns
# runs,delivery,batsman

def plot_runs_by_balls():

gr=ifl_df.groupby('batsman')
balls=pd.DataFrame(gr['delivery'].count())
runs=pd.DataFrame(gr['runs'].sum())

A=balls.merge(runs, left_index=True,right_index=True, how='inner')

plt.scatter(A.runs,A.delivery)
plt.xlabel=('runs')
plt.ylabel=('deliveries')

plt.show()

# runs

# plt.scatter(ifl_df[)


# Solution