Last active
February 19, 2020 05:23
-
-
Save aravindpai/302be97c671f31f24c1fbb6ca6de0b5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pp=powerplay_batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==6.shape[0] ).reset_index(name='no_of_balls') | |
middle=middle_batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==6].shape[0] ).reset_index(name='no_of_balls') | |
last=last_batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==6].shape[0] ).reset_index(name='no_of_balls') | |
# A python dictionary | |
data = {"Powerplay":pp['no_of_balls'].values, | |
"Middle overs":middle['no_of_balls'].values, | |
"Last 5 overs":last['no_of_balls'].values | |
}; | |
index = last['year'].values | |
# Dictionary loaded into a DataFrame | |
dataFrame = pd.DataFrame(data=data, index=index); | |
# Draw a vertical bar chart | |
axes = dataFrame.plot.bar(rot=0, title="Avg no. of balls to hit 6") | |
fig=axes.get_figure() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment