<jupyter_start><jupyter_text>Pivot to Game Outcome Prediction * pull historic play by play data for 25-30 years for all teams  * Calculate wOBA * Get wOBA weights possibly(fangraphs.com)<jupyter_code>!which sagemaker

# Inport all the things!
import pandas as pd 
import numpy as np 
import time 
import pybaseball as pb
from pybaseball import statcast
import sagemaker
seasons = {'2010':{'start_date': '2010-04-04', 'end_date': '2010-11-10'},
           '2011':{'start_date': '2011-03-31', 'end_date': '2011-10-28'},
           '2012':{'start_date': '2012-03-28', 'end_date': '2012-10-28'},
           '2013':{'start_date': '2013-03-31', 'end_date': '2013-10-30'},
           '2014':{'start_date': '2014-03-22', 'end_date': '2014-10-29'},
           '2015':{'start_date': '2015-04-05', 'end_date': '2015-11-01'},
           '2016':{'start_date': '2016-04-03', 'end_date': '2016-11-02'},
           '2017':{'start_date': '2017-04-02', 'end_date': '2017-11-01'},
           '2018':{'start_date': '2018-03-29', 'end_date': '2018-10-28'},
           '2019':{'start_date': '2019-03-20', 'end_date': '2019-10-30'}
           }


def pull_and_pack(start_date, end_date):

    # Pull in DataFrame from statcast
    df = statcast(start_dt = start_date, end_dt = end_date)

    # Sort pitches chronologically
#     df = df.sort_values(by = ['game_date', 'game_pk', 'at_bat_number', 'pitch_number'])

    # Drop DF into csv 
    df.to_csv('D:/baseball_data/season_'+year+'.csv')

for year in seasons.keys():
  start_date = seasons[year]['start_date']
  end_date = seasons[year]['end_date']
  pull_and_pack(start_date, end_date)
sess = sagemaker.Session()

# Uploading the local file to S3
sess.upload_data(path='local-file.txt', bucket=bucket_name, key_prefix='input')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1772930648769575, 'fraction_numerical': 0.11465324384787472, 'mean_word_length': 3.955678670360111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '54427', 'license': 'MIT', 'n_tokens_mistral': 794, 'n_tokens_neox': 646, 'n_words': 137, 'path': 'baseball_notebooks/Outcome prediction start(10-8-19).ipynb', 'repo_name': 'Dpgofast/baseball_predict', 'size': '1788'}