Skip to content

Commit 324c4de

Browse files
committed
fix(content): mismatch between content total and code average calc
1 parent f03049a commit 324c4de

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

projects/analyze-baseball-stats-with-pandas-and-matplotlib/analyze-baseball-stats-with-pandas-and-matplotlib.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Because baseball has such a long history, it can be interesting to see how the g
196196
First, let's find the total number of home runs per year. This will look very familiar to what we just did, except we're now grouping by `yearID`:
197197

198198
```py
199-
avg_hr_by_year = batting.groupby('yearID')['HR'].sum()
199+
total_hr_by_year = batting.groupby('yearID')['HR'].sum()
200200
```
201201

202202
We can now plot this using Matplotlib's `.plot()` function. This function needs a list of X and Y values. In our case, we want the year to be on the X axis and the total number of home runs to be on the Y axis:
@@ -205,12 +205,12 @@ We can now plot this using Matplotlib's `.plot()` function. This function needs
205205
import matplotlib.pyplot as plt
206206

207207
plt.figure(figsize=(10,6))
208-
plt.plot(avg_hr_by_year.index, avg_hr_by_year.values)
208+
plt.plot(total_hr_by_year.index, total_hr_by_year.values)
209209

210210
# Adding labels
211-
plt.title('Average Home Runs per Player Over Time')
211+
plt.title('Total Home Runs Over Time')
212212
plt.xlabel('Year')
213-
plt.ylabel('Avg Home Runs')
213+
plt.ylabel('Total Home Runs')
214214

215215
plt.grid(True)
216216
plt.show()

0 commit comments

Comments
 (0)