<jupyter_start><jupyter_text>Initialize a GameDataset and some sample operationsA GameDatset instance can contain tracking and events data in a TrackingFrame and EventsFrame respectively.<jupyter_code>import sys
sys.path.insert(1, '../../')

from codeball import GameDataset, Zones

metadata_file = (r"../../codeball/tests/files/metadata.xml")
tracking_file = (r"../../codeball/tests/files/tracking.txt")
events_file = (r"../../codeball/tests/files/events.json")

game_dataset = GameDataset(
    tracking_metadata_file=metadata_file,
    tracking_data_file=tracking_file,
    events_metadata_file=metadata_file,
    events_data_file=events_file,
)

print(type(game_dataset.tracking))
print(type(game_dataset.events))<jupyter_output><class 'codeball.codeball_frames.TrackingFrame'>
<class 'codeball.codeball_frames.EventsFrame'><jupyter_text>TrackingGameDataset.tracking holds a TrackingFrame with all the tacking data of the game.<jupyter_code>game_dataset.tracking.head()<jupyter_output><empty_output><jupyter_text>If you want to filter the TrackingFrame, you can use it's methods (on top of all standard DataFrame methods). For example to get a TrackingFrame only with the data of team with team_id `FIFATMA` you can do:<jupyter_code>game_dataset.tracking.team('FIFATMA').head()<jupyter_output><empty_output><jupyter_text>Final example, let's say you want to get the x coordiante data, only for the field players (excluding goalkeeper) for team_id `FIFATMA`, you can get that by doing:<jupyter_code>game_dataset.tracking.team('FIFATMA').players('field').dimension('x').head()<jupyter_output><empty_output><jupyter_text>EventsSimilarly, GameDataset.events holds a TrackingFrame with all the tacking data of the game, and if you want to filter it, you can do so using it's methods. For example to get all event that go into the opponent box you can do `game_dataset.events.into(Zones.OPPONENT_BOX)`, or if you want to get all the passes you can do:<jupyter_code>game_dataset.events.type('PASS').head()<jupyter_output><empty_output><jupyter_text>Since in this game tracking and event daa come from the same provider, GameDataset.metadata for this case is the same as GameDataset.tracking.metadata and GameDataset.events.metadata. There ou can access metadata about the data like frame rate, field dimensions, teams and players details, etc. Like:<jupyter_code>game_dataset.metadata.teams[0].players[5].name
game_dataset.metadata.frame_rate
game_dataset.metadata.score<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09615384615384616, 'fraction_numerical': 0.001201923076923077, 'mean_word_length': 6.70679012345679, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '276905', 'license': 'MIT', 'n_tokens_mistral': 770, 'n_tokens_neox': 761, 'n_words': 217, 'path': 'docs/examples/game_dataset.ipynb', 'repo_name': 'metrica-sports/codeball', 'size': '2496'}