Last active
February 19, 2020 05:36
-
-
Save aravindpai/7ef71c20059ed0b7c3980a90de41bec0 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
df_4 = batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==4].shape[0] ).reset_index(name='num_of_balls') | |
df_6 = batting_df.groupby('year').apply(lambda x: x.shape[0] / x[x['runs']==6].shape[0] ).reset_index(name='num_of_balls') | |
# A python dictionary | |
data = {"4":df_4['num_of_balls'].values, | |
"6":df_6['num_of_balls'].values | |
} | |
index = df_4['year'].values | |
# Dictionary loaded into a DataFrame | |
dataFrame = pd.DataFrame(data=data, index=index); | |
# Draw a vertical bar chart | |
fig = dataFrame.plot.bar(rot=0, title="Avg no. of balls to score boundary (year wise)",figsize=(10,8)).get_figure() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment