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()
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
Post a Comment