Skip to content

Instantly share code, notes, and snippets.



Last active Feb 19, 2020
What would you like to do?
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 =, title="Avg no. of balls to hit 6")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.