def test_filter(self, dataset: EventDataset): """ Test filtering allows simple 'css selector' (<event_type>.<result>) """ goals_dataset = dataset.filter("shot.goal") df = goals_dataset.to_pandas() assert df["event_id"].to_list() == [ "4c7c4ab1-6b9f-4504-a237-249c2e0c549f", "683c6752-13bc-4892-94ed-22e1c938f1f7", "55d71847-9511-4417-aea9-6f415e279011", ]
def test_string_columns(self, dataset: EventDataset): """ When string columns passed to to_records the data must be searched from: 1. the output of Default() 2. attributes of the event """ records = dataset.filter("pass").to_records("timestamp", "coordinates_x", "coordinates") assert records[0] == { "timestamp": 0.098, "coordinates_x": 60.5, "coordinates": Point(x=60.5, y=40.5), }
def test_string_wildcard_columns(self, dataset: EventDataset): """ Make sure it's possible to specify wildcard pattern to match attributes. """ records = dataset.filter("pass").to_records( "timestamp", "player_id", "coordinates_*", DistanceToGoalTransformer(), ) assert records[0] == { "timestamp": 0.098, "player_id": "6581", "coordinates_x": 60.5, "coordinates_y": 40.5, "distance_to_goal": 59.50210080324896, }