Skip to content

Instantly share code, notes, and snippets.

@aravindpai

aravindpai/cc_19.py

Last active Feb 19, 2020
Embed
What would you like to do?
pp=powerplay_batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==4.shape[0] ).reset_index(name='no_of_balls')
middle=middle_batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==4].shape[0] ).reset_index(name='no_of_balls')
last=last_batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==4].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 4")
fig=axes.get_figure()
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.