Bar graph from dataframe groupby

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

Plot using pandas.DataFrame.plot

Updated to pandas v1.2.4 and matplotlib v3.3.4

then using your code

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

dfg.plot(kind='bar', title='Arrests', ylabel='Mean Arrests',
         xlabel='Home Team', figsize=(6, 5))

enter image description here


Good one by @piRSuared, and I just beautified their 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()