Skip to content

Commit

Permalink
Fixed bugs in YAML Files when running in the offseason.
Browse files Browse the repository at this point in the history
  • Loading branch information
armstjc committed Dec 2, 2023
1 parent 1bff7e5 commit a6c7564
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update_milb_pbp_a+.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Update MiLB PBP - A+
on:
schedule:
- cron: "0 7 * 3-9 *"
- cron: "0 0 3 10-12,1-3 *"
# push:
# branches: [main]
# pull_request:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_milb_pbp_a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Update MiLB PBP - A
on:
schedule:
- cron: "0 8 * 3-9 *"

- cron: "0 0 2 10-12,1-3 *"
# push:
# branches: [main]
# pull_request:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update_milb_pbp_aa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Update MiLB PBP - AA
on:
schedule:
- cron: "0 6 * 3-9 *"
- cron: "0 0 4 10-12,1-3 *"
# push:
# branches: [main]
# pull_request:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update_milb_pbp_aaa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Update MiLB PBP - AAA
on:
schedule:
- cron: "0 5 * 3-9 *"
- cron: "0 0 5 10-12,1-3 *"
# push:
# branches: [main]
# pull_request:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update_milb_pbp_rk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Update MiLB PBP - Rookie Ball
on:
schedule:
- cron: "0 9 * 5-9 *"
- cron: "0 0 1 10-12,1-3 *"
# push:
# branches: [main]
# pull_request:
Expand Down
44 changes: 22 additions & 22 deletions README.md

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions get_milb_pbp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import time
from datetime import datetime
from urllib.request import urlopen
import warnings
import numpy as np

import pandas as pd
from tqdm import tqdm

from get_milb_schedule import get_milb_schedule

warnings.filterwarnings("ignore", category=FutureWarning)

def get_milb_game_pbp(game_id: int, cache_data=False, cache_dir=""):
"""
Expand Down Expand Up @@ -848,7 +851,8 @@ def get_milb_game_pbp(game_id: int, cache_data=False, cache_dir=""):
fielder_2, fielder_3, fielder_4,\
fielder_5, fielder_6, fielder_7,\
fielder_8, fielder_9


game_df.fillna(value=np.NaN,inplace=True)
game_df = pd.concat([game_df, play_df], ignore_index=True)

del is_pitch
Expand Down Expand Up @@ -947,7 +951,14 @@ def get_month_milb_pbp(season: int, month: int, level="AAA", cache_data=False, c

season = args.season

if season == now.year and now.day <= 2 and platform.system() == "Windows":
if season == now.year and now.month >= 11:
start_month = now.month - 5
end_month = now.month - 4
elif season == now.year and now.month <=3:
start_month = now.month + 3
end_month = now.month + 4
season -= 1
elif season == now.year and now.day <= 2 and platform.system() == "Windows":
# This is here to ensure that a game being played
# in between 2 months
# (like a game starting on March 31st but ending on April 1st)
Expand Down
18 changes: 9 additions & 9 deletions get_milb_player_game_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,15 @@ def get_month_milb_player_game_stats(season: int, month: int, level="AAA", cache
print('HEY!\nThat\'s a ton of data you want to access.\nPlease cache this data in the future to avoid severe data loss!')

for game_id in tqdm(game_ids_arr):
# try:
# game_df = get_milb_player_game_stats(
# game_id=game_id, cache_data=cache_data, cache_dir=cache_dir)
# stats_df = pd.concat([stats_df, game_df], ignore_index=True)
# except Exception as e:
# print(f'Unhandled use case. Error Details:\n{e}')

game_df = get_milb_player_game_stats(
game_id=game_id, cache_data=cache_data, cache_dir=cache_dir)
try:
game_df = get_milb_player_game_stats(
game_id=game_id, cache_data=cache_data, cache_dir=cache_dir)
stats_df = pd.concat([stats_df, game_df], ignore_index=True)
except Exception as e:
print(f'Unhandled use case. Error Details:\n{e}')

# game_df = get_milb_player_game_stats(
# game_id=game_id, cache_data=cache_data, cache_dir=cache_dir)
stats_df = pd.concat([stats_df, game_df], ignore_index=True)

if save == True and len(stats_df) > 0:
Expand Down

0 comments on commit a6c7564

Please sign in to comment.