Bar Graph From Dataframe Groupby


Answer :

copying data from your link and running df = pd.read_clipboard()

then using your code

df = df.replace(np.nan,0) df = df.groupby(['home_team'])['arrests'].mean()  df.plot.bar() 

enter image description here


Good one by @piRSuared, and I just buitified his answer :)

## referenced to the answer by @piRSquared df = df.replace(np.nan,0) df = df.groupby(['home_team'])['arrests'].mean()  ax = df.plot(kind='bar', figsize=(10,6), color="indigo", fontsize=13); ax.set_alpha(0.8) ax.set_title("My Bar Plot", fontsize=22) ax.set_ylabel("Some Heading on Y-Axis", fontsize=15); plt.show() 

Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?