Skip to content

Commit

Permalink
Merge pull request #52 from armstjc/51-player-id-not-parsed-correctly…
Browse files Browse the repository at this point in the history
…-in-cfbd_json_pyplayersget_cfbd_player_season_stats

0.2.3 The "Hotfix" Update.
  • Loading branch information
armstjc authored Aug 29, 2024
2 parents 710dbc8 + 0ceff88 commit 33c2906
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG: cfbd_json_py

## 0.2.3 The "Hotfix" Update.
- Fixed an issue raised in #51 where the `[player_id]` column would be entirely blank in `cfbd_json_py.players.get_cfbd_player_season_stats()`.
- Updated the package version to `0.2.3`.

## 0.2.2 The "Version Bump" Update
- Updated the package version to `0.2.2`.

## 0.2.1 The "College Football is BACK! (2024)" Update
- Fixed a bug in `cfbd_json_py.drives.get_cfbd_drives_info()` where the `ncaa_division` parameter would become malformed, the API call wouldn't filter by `ncaa_division`, but the API call would still be accepted.
- Updated the package to comply with changes made in version `4.6.0` of the CFBD V1 API. These changes in this API version removed the `game_id` parameter from `cfbd_json_py.betting.get_cfbd_betting_lines()` and from `cfbd_json_py.games.get_cfbd_weather_info()`.
Expand Down
21 changes: 20 additions & 1 deletion cfbd_json_py/players.py
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,7 @@ def get_cfbd_player_season_stats(

if s_category == "passing":
if s_type == "COMPLETIONS":
rebuilt_json[player_id]["player_id"] = player_name
rebuilt_json[player_id]["player_name"] = player_name
rebuilt_json[player_id]["team_name"] = team_name
rebuilt_json[player_id]["team_conference"] = team_conference
Expand Down Expand Up @@ -2103,6 +2104,7 @@ def get_cfbd_player_season_stats(

for key, value in tqdm(rebuilt_json.items()):
row_df = pd.json_normalize(value)
row_df["player_id"] = key
final_df = pd.concat([final_df, row_df], ignore_index=True)
del row_df

Expand Down Expand Up @@ -2136,34 +2138,42 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["passing_ATT"] > 0, "passing_COMP%"] = (
final_df["passing_COMP"] / final_df["passing_ATT"]
)
final_df["passing_COMP%"] = final_df["passing_COMP%"].round(3)

final_df.loc[final_df["rushing_CAR"] > 0, "rushing_AVG"] = (
final_df["rushing_YDS"] / final_df["rushing_CAR"]
)
final_df["rushing_AVG"] = final_df["rushing_AVG"].round(3)

final_df.loc[final_df["receiving_REC"] > 0, "receiving_AVG"] = (
final_df["receiving_YDS"] / final_df["receiving_REC"]
)
final_df["receiving_AVG"] = final_df["receiving_AVG"].round(3)

final_df.loc[final_df["punting_NO"] > 0, "punting_AVG"] = (
final_df["punting_YDS"] / final_df["punting_NO"]
)
final_df["punting_AVG"] = final_df["punting_AVG"].round(3)

final_df.loc[final_df["kicking_FGA"] > 0, "kicking_FG%"] = (
final_df["kicking_FGM"] / final_df["kicking_FGA"]
)
final_df["kicking_FG%"] = final_df["kicking_FG%"].round(5)

final_df.loc[final_df["kicking_XPA"] > 0, "kicking_XP%"] = (
final_df["kicking_XPM"] / final_df["kicking_XPA"]
)
final_df["kicking_XP%"] = final_df["kicking_XP%"].round(5)

final_df.loc[final_df["kickReturns_NO"] > 0, "kickReturns_AVG"] = (
final_df["kickReturns_YDS"] / final_df["kickReturns_NO"]
)
final_df["kickReturns_AVG"] = final_df["kickReturns_AVG"].round(3)

final_df.loc[final_df["puntReturns_NO"] > 0, "puntReturns_AVG"] = (
final_df["puntReturns_YDS"] / final_df["puntReturns_NO"]
)
final_df["puntReturns_AVG"] = final_df["puntReturns_AVG"].round(3)

elif filter_by_stat_category is True and stat_category == "passing":
try:
Expand All @@ -2184,12 +2194,14 @@ def get_cfbd_player_season_stats(
final_df["passing_COMP"] / final_df["passing_ATT"]
)

final_df["passing_COMP%"] = final_df["passing_COMP%"].round(3)

final_df = final_df[
[
"season",
"team_name",
"team_conference",
# "player_id",
"player_id",
"player_name",
# PASS
"passing_COMP",
Expand Down Expand Up @@ -2218,6 +2230,7 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["rushing_CAR"] >= 1, "rushing_AVG"] = (
final_df["rushing_YDS"] / final_df["rushing_CAR"]
)
final_df["rushing_AVG"] = final_df["rushing_AVG"].round(3)

final_df = final_df[
[
Expand Down Expand Up @@ -2253,6 +2266,7 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["receiving_REC"] > 0, "receiving_AVG"] = (
final_df["receiving_YDS"] / final_df["receiving_REC"]
)
final_df["receiving_AVG"] = final_df["receiving_AVG"].round(3)

final_df = final_df[
[
Expand Down Expand Up @@ -2337,6 +2351,7 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["punting_NO"] > 0, "punting_AVG"] = (
final_df["punting_YDS"] / final_df["punting_NO"]
)
final_df["punting_AVG"] = final_df["punting_AVG"].round(3)

final_df = final_df[
[
Expand Down Expand Up @@ -2378,10 +2393,12 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["kicking_FGA"] > 0, "kicking_FG%"] = (
final_df["kicking_FGM"] / final_df["kicking_FGA"]
)
final_df["kicking_FG%"] = final_df["kicking_FG%"].round(5)

final_df.loc[final_df["kicking_XPA"] > 0, "kicking_XP%"] = (
final_df["kicking_XPM"] / final_df["kicking_XPA"]
)
final_df["kicking_XP%"] = final_df["kicking_XP%"].round(5)

final_df = final_df[
[
Expand Down Expand Up @@ -2418,6 +2435,7 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["kickReturns_NO"] > 0, "kickReturns_AVG"] = (
final_df["kickReturns_YDS"] / final_df["kickReturns_NO"]
)
final_df["kickReturns_AVG"] = final_df["kickReturns_AVG"].round(3)

final_df = final_df[
[
Expand Down Expand Up @@ -2453,6 +2471,7 @@ def get_cfbd_player_season_stats(
final_df.loc[final_df["puntReturns_NO"] > 0, "puntReturns_AVG"] = (
final_df["puntReturns_YDS"] / final_df["puntReturns_NO"]
)
final_df["puntReturns_AVG"] = final_df["puntReturns_AVG"].round(3)

final_df = final_df[
[
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "cfbd_json_py"
version = "0.2.2"
version = "0.2.3"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "MIT"}
Expand Down

0 comments on commit 33c2906

Please sign in to comment.