Skip to content

Instantly share code, notes, and snippets.

@aravindpai

aravindpai/cc_15.py

Created Feb 16, 2020
Embed
What would you like to do?
#bowling strike rate
sr1 = powerplay_bowling_df.shape[0]/(powerplay_bowling_df[powerplay_bowling_df['event']=='out'].shape[0])
sr2 = middle_bowling_df.shape[0]/(middle_bowling_df[middle_bowling_df['event']=='out'].shape[0])
sr3 = last_bowling_df.shape[0]/(last_bowling_df[last_bowling_df['event']=='out'].shape[0])
#bowling average
avg1=np.sum(powerplay_bowling_df['runs'].values)/(powerplay_bowling_df[powerplay_bowling_df['event']=='out'].shape[0])
avg2=np.sum(middle_bowling_df['runs'].values)/(middle_bowling_df[middle_bowling_df['event']=='out'].shape[0])
avg3=np.sum(last_bowling_df['runs'].values)/(last_bowling_df[last_bowling_df['event']=='out'].shape[0])
# A python dictionary
data = {"Strike rate":[sr1,sr2,sr3],
"Bowling average":[avg1,avg2,avg3]
}
index = ["Powerplay", "Middle", "Last 5 overs"];
# Dictionary loaded into a DataFrame
dataFrame = pd.DataFrame(data=data, index=index);
# Draw a vertical bar chart
fig = dataFrame.plot.bar(rot=0, title="Team India bowling performance").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.