In [1]:
%matplotlib inline
import csv
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from retrosheet_controller import RetroSheetDataController
from analyze_batter import AnalyzeBatter

In [2]:
# Data controller
client = RetroSheetDataController()
# 分析用のUtilクラス(引数:RETROSHEETを取り扱う用のUtilクラス)
analyzer = AnalyzeBatter()

In [3]:
# 2004年および2011年の松井秀喜成績データを読み込む
df2004 = client.batter_event_by_hits('Hideki', 'Matsui', 2004)
df2011 = client.batter_event_by_hits('Hideki', 'Matsui', 2011)

In [4]:
# 内野・外野に飛んだ打球をヒットの種類ごとに数え上げ
hit_charts2004 = analyzer.hit_location_data(df2004)
hit_charts2011 = analyzer.hit_location_data(df2011)

In [5]:
# 棒グラフとして表示(2004年、外野)
dfpos2004 = pd.DataFrame(hit_charts2004.get('of'))
dfpos2004.T.plot(kind='bar', stacked=True, ylim=(0, 100), title='Hideki Matsui(2004/NYY)')


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x1076f0be0>

In [6]:
# 棒グラフとして表示(2011年、外野)

dfpos2011 = pd.DataFrame(hit_charts2011.get('of'))
dfpos2011.T.plot(kind='bar', stacked=True, ylim=(0, 100), title='Hideki Matsui(2011/OAK)')


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x10779dc18>

In [8]:
from retrosheet_util import RetroSheetUtil
for i, row in df2004.iterrows():
    atbat = row.to_dict()
    pitch_seq = RetroSheetUtil.get_pitch_sequence(atbat.get('pitch_seq_tx'), atbat.get('event_cd'))
    print(pitch_seq)


{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'foul', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'swinging strike', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'foul', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['marker for play not involving the batter', 'marker for play not involving the batter', 'called strike', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 11, 'strike': 7, 'pickoff': 1, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['called strike', 'called strike', 'foul', 'ball', 'foul', 'ball', 'following pickoff throw by the catcher', 'pickoff throw to first', 'ball', 'foul', 'foul', 'indicates a runner going on the pitch', 'foul', 'indicates a runner going on the pitch', 'ball put into play by batter'], 'ball': 3}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'swinging strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('S',), 'seq': ['indicates the following pitch was blocked by the catcher', 'ball', 'indicates the following pitch was blocked by the catcher', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'swinging strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 5, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('S',), 'seq': ['called strike', 'ball', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'ball put into play by batter'], 'ball': 0}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball', 'called strike', 'called strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['called strike', 'ball', 'foul', 'ball', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'indicates a runner going on the pitch', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 0, 'pickoff': 1, 'ball_count': {'strike': 0, 'ball': 3}, 'event': ('DGR', 'D'), 'seq': ['ball', 'pickoff throw to first', 'ball', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball', 'foul', 'ball', 'indicates a runner going on the pitch', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 5, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'called strike', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 2}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 6, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['ball', 'foul', 'called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('HR',), 'seq': ['indicates the following pitch was blocked by the catcher', 'ball', 'foul tip', 'called strike', 'foul', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'called strike', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['swinging strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'called strike', 'foul', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('T',), 'seq': ['marker for play not involving the batter', 'marker for play not involving the batter', 'marker for play not involving the batter', 'ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('HR',), 'seq': ['marker for play not involving the batter', 'called strike', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'called strike', 'called strike', 'ball', 'indicates a runner going on the pitch', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'called strike', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 6, 'strike': 2, 'pickoff': 1, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['pickoff throw to first', 'ball', 'ball', 'ball', 'swinging strike', 'called strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('HR',), 'seq': ['foul', 'called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('T',), 'seq': ['marker for play not involving the batter', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'called strike', 'foul', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('S',), 'seq': ['indicates the following pitch was blocked by the catcher', 'ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('HR',), 'seq': ['ball', 'called strike', 'ball', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['marker for play not involving the batter', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 7, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'called strike', 'called strike', 'foul', 'indicates a runner going on the pitch', 'ball', 'marker for play not involving the batter', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'called strike', 'foul', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 2, 'pickoff': 1, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'pickoff throw to first', 'swinging strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['marker for play not involving the batter', 'called strike', 'ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['foul', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['marker for play not involving the batter', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 5, 'strike': 4, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'foul', 'foul', 'foul', 'ball put into play by batter'], 'ball': 0}
{'pitches': 7, 'strike': 4, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('S',), 'seq': ['called strike', 'ball', 'called strike', 'ball', 'foul', 'foul', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'called strike', 'foul', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'ball', 'foul', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 4, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['foul', 'foul', 'foul', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['swinging strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'foul', 'ball', 'swinging strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('HR',), 'seq': ['swinging strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 7, 'strike': 4, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('S',), 'seq': ['called strike', 'ball', 'foul tip', 'foul', 'ball', 'foul', 'ball put into play by batter'], 'ball': 2}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball', 'swinging strike', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 2}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['pitchout', 'ball', 'called strike', 'called strike', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 7, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'called strike', 'ball', 'called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 1, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['pickoff throw to first', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('HR',), 'seq': ['ball', 'ball', 'swinging strike', 'ball put into play by batter'], 'ball': 2}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'ball', 'foul', 'ball', 'indicates a runner going on the pitch', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'foul', 'ball put into play by batter'], 'ball': 2}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('HR',), 'seq': ['swinging strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['indicates a runner going on the pitch', 'ball', 'marker for play not involving the batter', 'called strike', 'ball', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['foul', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'foul', 'ball put into play by batter'], 'ball': 0}
{'pitches': 7, 'strike': 2, 'pickoff': 2, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('S',), 'seq': ['pitchout', 'called strike', 'pickoff throw to first', 'called strike', 'ball', 'ball', 'pickoff throw to first', 'no pitch (on balks and interference calls)', 'marker for play not involving the batter', 'ball put into play by batter'], 'ball': 2}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('HR',), 'seq': ['foul', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['indicates the following pitch was blocked by the catcher', 'ball', 'foul', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 1, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['pickoff throw to first', 'ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'called strike', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['foul', 'ball', 'ball', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['called strike', 'ball', 'called strike', 'ball', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 6, 'strike': 4, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'foul', 'foul', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 6, 'strike': 2, 'pickoff': 1, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'foul', 'ball', 'pickoff throw to first', 'ball', 'foul', 'indicates a runner going on the pitch', 'ball put into play by batter'], 'ball': 3}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 0, 'pickoff': 1, 'ball_count': {'strike': 0, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['marker for play not involving the batter', 'ball', 'ball', 'pickoff throw to first', 'ball put into play by batter'], 'ball': 2}
{'pitches': 5, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 3}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 7, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'foul', 'ball', 'called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 3}
{'pitches': 7, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'foul', 'called strike', 'ball', 'foul', 'ball', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('HR',), 'seq': ['called strike', 'ball', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 3, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 0}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('S',), 'seq': ['ball', 'foul', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 4, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 4, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 2}, 'event': ('S',), 'seq': ['marker for play not involving the batter', 'ball', 'swinging strike', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 6, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('S',), 'seq': ['ball', 'swinging strike', 'ball', 'ball', 'called strike', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('S',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 0}, 'event': ('S',), 'seq': ['called strike', 'ball put into play by batter'], 'ball': 0}
{'pitches': 7, 'strike': 4, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('DGR', 'D'), 'seq': ['foul', 'ball', 'ball', 'called strike', 'foul', 'foul', 'ball put into play by batter'], 'ball': 2}
{'pitches': 5, 'strike': 2, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 2}, 'event': ('S',), 'seq': ['called strike', 'ball', 'foul', 'ball', 'ball put into play by batter'], 'ball': 2}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('S',), 'seq': ['called strike', 'ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 7, 'strike': 3, 'pickoff': 3, 'ball_count': {'strike': 2, 'ball': 3}, 'event': ('DGR', 'D'), 'seq': ['ball', 'pickoff throw to first', 'foul', 'pickoff throw to first', 'pickoff throw to first', 'ball', 'called strike', 'foul', 'ball', 'ball put into play by batter'], 'ball': 3}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 1, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 0}, 'event': ('HR',), 'seq': ['ball put into play by batter'], 'ball': 0}
{'pitches': 5, 'strike': 3, 'pickoff': 0, 'ball_count': {'strike': 2, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['called strike', 'called strike', 'ball', 'foul', 'ball put into play by batter'], 'ball': 1}
{'pitches': 3, 'strike': 1, 'pickoff': 0, 'ball_count': {'strike': 1, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'called strike', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('HR',), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}
{'pitches': 2, 'strike': 0, 'pickoff': 0, 'ball_count': {'strike': 0, 'ball': 1}, 'event': ('DGR', 'D'), 'seq': ['ball', 'ball put into play by batter'], 'ball': 1}

In [ ]: