floodlight.io.statsbomb

floodlight.io.statsbomb.read_open_event_data_json(filepath_events, filepath_match, filepath_threesixty=None, teamsheet_home=None, teamsheet_away=None)[source]

Parses files for a single match from the StatsBomb open dataset and extracts the event data and teamsheets.

This function provides high-level access to an events json file from the openly published StatsBomb open data and returns Event- and Teamsheet-objects for both teams for the full match. A StatsBomb360 json file can be passed to the function to include StatsBomb360 data to the qualifier column. Requires the parsed files from the dataset to maintain their original names from the official data repository

Parameters
  • filepath_events (str or pathlib.Path) – Full path to json file where the Event data is saved.

  • filepath_match (str or pathlib.Path) – Full path to json file where information about all matches of a season are stored.

  • filepath_threesixty (str or pathlib.Path, optional) – Full path to json file where the StatsBomb360 data in is saved if available. The information about the area of the field where player positions are tracked (visible_area) and player positions at single events (freeze frame) are stored as a string in the qualifier column.

  • teamsheet_home (Teamsheet, optional) – Teamsheet-object for the home team used to create link dictionaries of the form links[pID] = team. If given as None (default), teamsheet is extracted from the events and match json files.

  • teamsheet_away (Teamsheet, optional) – Teamsheet-object for the away team. If given as None (default), teamsheet is extracted from the events and match json files. See teamsheet_home for details.

Returns

data_objects – Tuple of (nested) floodlight core objects with shape (events_objects, teamsheets).

events_objects is a nested dictionary containing Events objects for each team and segment of the form events_objects[segment][team] = Events. For a typical league match with two halves and teams this dictionary looks like: {'HT1': {'Home': Events, 'Away': Events}, 'HT2': {'Home': Events, 'Away': Events}}.

teamsheets is a dictionary containing Teamsheet objects for each team of the form teamsheets[team] = Teamsheet.

Return type

Tuple[Dict[str, Dict[str, Events]], Dict[str, Teamsheet]]

Notes

StatsBomb’s open format of handling provides certain additional event attributes, which attach additional information to certain events. As of now, these information are parsed as a string in the qualifier column of the returned DataFrame and can be transformed to a dict of form {attribute: value}. This includes the information about the tracked position of (some) players and the visible area that is included in the StatsBomb360 data.

floodlight.io.statsbomb.read_teamsheets_from_open_event_data_json(filepath_events, filepath_match)[source]

Reads open events and match files and returns Teamsheet objects for the home and the away team.

Parameters
  • filepath_events (str or pathlib.Path) – Full path to json file where the Event data is saved.

  • filepath_match (str or pathlib.Path) – Full path to json file where information about all matches of a season are stored.

Returns

teamsheets – Dictionary with teamsheets for the home team and the away team.

Return type

Dict[str, Teamsheet]