statsbomb/statsbombpy

360 metrics not available in open data

LeonardoAcquaroli opened this issue · 1 comments

Contact Details

No response

Version

1.0.1

What platform are you seeing the problem on?

Windows

What Python version are you running, are you using a virtual environment? Give us as much info as you can.

Python 3.11.5, on a venv.

What happened?

After reading this blog page and this blog page about European cup free 360 data I wanted to pull them off but apparently I am not able to.

EDIT
I just modified the events function in the file sb.py by commenting the if condition that threw the Exception as below 👇🏻

def events(
    match_id: int,
    split: bool = False,
    filters: dict = {},
    fmt: str = "dataframe",
    flatten_attrs: bool = True,
    creds: dict = DEFAULT_CREDS,
    include_360_metrics=False,
) -> Union[pd.DataFrame, dict]:

    # if not api_client.has_auth(creds) and include_360_metrics:
    #     raise Exception("360 metrics not available in open data")
    if api_client.has_auth(creds) is True:
        events = api_client.events(match_id, creds=creds)
    else:
        events = public.events(match_id)

    if include_360_metrics:
        frames = _360_frames(match_id, creds=creds)
        events = merge_events_and_frames(events, frames)

    if fmt == "dataframe":
        events = filter_and_group_events(events, filters, fmt, flatten_attrs)
        for ev_type, evs in events.items():
            events[ev_type] = pd.DataFrame(evs)
        if split is False:
            events = pd.concat([*events.values()], axis=0, ignore_index=True, sort=True)
    return events

Yet my question is still open: is it supposed to be normal even if you publicly say they are free?

Relevant log output

Exception: 360 metrics not available in open data

Code to reproduce issue

from statsbombpy import sb
comp_events = sb.competition_events(
            country="Europe",
            division="UEFA Euro",
            season="2020",
            gender='male',
            include_360_metrics=True
)
comp_events

Attempted solutions

No response

This is indeed the expected behaviour - we provide the raw 360 data for free but the metrics that use the 360 data are for customers only sorry. You can use the frames() functions to access the 360 data and of course, you can create your own versions of the metrics using that data.