Skip to content

Commit c0e788c

Browse files
authored
Update analyze-baseball-stats-with-pandas-and-matplotlib.mdx
1 parent 60f45ea commit c0e788c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,10 @@ plt.legend()
284284
plt.show()
285285
```
286286

287+
The graph should look like:
288+
289+
![The graph](https://raw.githubusercontent.com/codedex-io/projects/refs/heads/main/projects/analyze-baseball-stats-with-pandas-and-matplotlib/colorado-rockies.png)
290+
287291
As expected, the altitude in Denver has caused some pretty high home run numbers!
288292

289293
## Replicating Moneyball
@@ -310,13 +314,14 @@ batting[['BB', 'HBP', 'SF']] = batting[['BB', 'HBP', 'SF']].fillna(0)
310314

311315
# Create OBP column
312316
batting['OBP'] = (
313-
(batting['H'] + batting['BB'] + batting['HBP']) /
314-
(batting['AB'] + batting['BB'] + batting['HBP'] + batting['SF'])
317+
(batting['H'] + batting['BB'] + batting['HBP']) /
318+
(batting['AB'] + batting['BB'] + batting['HBP'] + batting['SF'])
315319
)
316320

317321
# If we got NaN due to no plate appearances, then fill with 0.
318322
batting['OBP'] = batting['OBP'].fillna(0)
319323
```
324+
320325
A decent OBP is around `.3` to `.4`, and if we do a quick scan of the data, we can see values around that range:
321326

322327

0 commit comments

Comments
 (0)