Skip to content

Commit f03049a

Browse files
committed
fix(calculation): syntax error and calculation of OBP
1 parent 81f3f07 commit f03049a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,15 @@ value_df = batting_with_salary[
373373
We now have a DataFrame named `value_df` that contains only the rows we're interested in. Let's calculate each player's value and sort by the highest value players! We'll display only the columns that are relevant to us.
374374

375375
```py
376+
# Calculate OBP per dollar
377+
value_df['OBP_per_dollar'] = value_df['OBP'] / value_df['salary']
378+
376379
value_df_sorted = value_df.sort_values(
377380
by='OBP_per_dollar',
378381
ascending=False
379382
)
380383

381-
value_df_sorted [[
384+
value_df_sorted[[
382385
'playerID',
383386
'yearID',
384387
'teamID',
@@ -420,7 +423,7 @@ Clearly there is a _ton_ that you can do with this dataset.
420423
To recap, in this project tutorial, we practiced the following skills in Pandas:
421424

422425
- Initial data exploration using `.describe()` to see summary statistics.
423-
- Filtering the dataset by boolean values (for example, `[value_df_sorted['yearID'] == 2010`)
426+
- Filtering the dataset by boolean values (for example, `value_df_sorted['yearID'] == 2010`)
424427
- Grouping rows together and using aggregate functions like `.sum()` or `.mean()`.
425428
- Using Matplotlib to graph the results of Pandas operations.
426429
- Using `.merge()` to join two tables together.

0 commit comments

Comments
 (0)