diff --git a/docs/changelog.md b/docs/changelog.md index 7a31787b..813ea6c7 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,6 +3,17 @@ Find out all changes between different kloppy versions +## 3.8.0 (2023-03-05) + +Pull requests merged: +- Fix for Incorrect home/away mapping in Statsbomb metadata ([#174](https://github.com/PySport/kloppy/pull/174)) +- Added extra formations ([#166](https://github.com/PySport/kloppy/pull/166)) +- Set correct orientation for Metrica EPTS ([#168](https://github.com/PySport/kloppy/pull/168)) +- Add polars support ([#172](https://github.com/PySport/kloppy/pull/172)) + +Important changes: +- `to_pandas` is deprecated, `to_df` should be used. `to_df` is now a method on all Dataset types (event, tracking and code), and accepts an additional `engine` keyword argument that can be `polars` or `pandas`. The default value is `pandas` but can be changed using the config variable `dataframe.engine` + ## 3.7.1 (2023-01-16) Pull requests merged: diff --git a/docs/examples/event_data.ipynb b/docs/examples/event_data.ipynb index 10fb241f..191f8c01 100644 --- a/docs/examples/event_data.ipynb +++ b/docs/examples/event_data.ipynb @@ -957,6 +957,503 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Polars\n", + "\n", + "Since version 3.8.0 it's possible to export a `Dataset` to a [Polars](https://www.pola.rs/) dataframe." + ] + }, + { + "cell_type": "code", + "execution_count": 78, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "shape: (5, 19)\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
\n", + "event_id\n", + "\n", + "event_type\n", + "\n", + "result\n", + "\n", + "success\n", + "\n", + "period_id\n", + "\n", + "timestamp\n", + "\n", + "end_timestamp\n", + "\n", + "ball_state\n", + "\n", + "ball_owning_team\n", + "\n", + "team_id\n", + "\n", + "player_id\n", + "\n", + "coordinates_x\n", + "\n", + "coordinates_y\n", + "\n", + "end_coordinates_x\n", + "\n", + "end_coordinates_y\n", + "\n", + "receiver_player_id\n", + "\n", + "set_piece_type\n", + "\n", + "body_part_type\n", + "\n", + "pass_type\n", + "
\n", + "str\n", + "\n", + "str\n", + "\n", + "str\n", + "\n", + "bool\n", + "\n", + "i64\n", + "\n", + "f64\n", + "\n", + "f64\n", + "\n", + "str\n", + "\n", + "str\n", + "\n", + "str\n", + "\n", + "str\n", + "\n", + "f64\n", + "\n", + "f64\n", + "\n", + "f64\n", + "\n", + "f64\n", + "\n", + "str\n", + "\n", + "str\n", + "\n", + "str\n", + "\n", + "str\n", + "
\n", + ""19edeac2-e63f-...\n", + "\n", + ""GENERIC:Starti...\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "1\n", + "\n", + "0.0\n", + "\n", + "null\n", + "\n", + ""alive"\n", + "\n", + ""909"\n", + "\n", + ""909"\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "
\n", + ""89072e2e-b64f-...\n", + "\n", + ""GENERIC:Starti...\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "1\n", + "\n", + "0.0\n", + "\n", + "null\n", + "\n", + ""alive"\n", + "\n", + ""909"\n", + "\n", + ""914"\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "
\n", + ""46c6901e-3b12-...\n", + "\n", + ""GENERIC:Half S...\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "1\n", + "\n", + "0.0\n", + "\n", + "null\n", + "\n", + ""alive"\n", + "\n", + ""909"\n", + "\n", + ""914"\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "
\n", + ""9e5b0646-91cc-...\n", + "\n", + ""GENERIC:Half S...\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "1\n", + "\n", + "0.0\n", + "\n", + "null\n", + "\n", + ""alive"\n", + "\n", + ""909"\n", + "\n", + ""909"\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "\n", + "null\n", + "
\n", + ""bbc398f7-c784-...\n", + "\n", + ""PASS"\n", + "\n", + ""COMPLETE"\n", + "\n", + "true\n", + "\n", + "1\n", + "\n", + "0.878\n", + "\n", + "2.788504\n", + "\n", + ""alive"\n", + "\n", + ""909"\n", + "\n", + ""909"\n", + "\n", + ""11086"\n", + "\n", + "59.95\n", + "\n", + "39.95\n", + "\n", + "32.45\n", + "\n", + "28.75\n", + "\n", + ""8963"\n", + "\n", + ""KICK_OFF"\n", + "\n", + ""RIGHT_FOOT"\n", + "\n", + "null\n", + "
\n", + "
" + ], + "text/plain": [ + "shape: (5, 19)\n", + "┌─────────┬──────────┬──────────┬─────────┬─────┬────────────┬────────────┬────────────┬───────────┐\n", + "│ event_i ┆ event_ty ┆ result ┆ success ┆ ... ┆ receiver_p ┆ set_piece_ ┆ body_part_ ┆ pass_type │\n", + "│ d ┆ pe ┆ --- ┆ --- ┆ ┆ layer_id ┆ type ┆ type ┆ --- │\n", + "│ --- ┆ --- ┆ str ┆ bool ┆ ┆ --- ┆ --- ┆ --- ┆ str │\n", + "│ str ┆ str ┆ ┆ ┆ ┆ str ┆ str ┆ str ┆ │\n", + "╞═════════╪══════════╪══════════╪═════════╪═════╪════════════╪════════════╪════════════╪═══════════╡\n", + "│ 19edeac ┆ GENERIC: ┆ null ┆ null ┆ ... ┆ null ┆ null ┆ null ┆ null │\n", + "│ 2-e63f- ┆ Starting ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 4795-8a ┆ XI ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 8b-17a6 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ e9fd... ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 89072e2 ┆ GENERIC: ┆ null ┆ null ┆ ... ┆ null ┆ null ┆ null ┆ null │\n", + "│ e-b64f- ┆ Starting ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 4099-84 ┆ XI ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 6b-b22c ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ f000... ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 46c6901 ┆ GENERIC: ┆ null ┆ null ┆ ... ┆ null ┆ null ┆ null ┆ null │\n", + "│ e-3b12- ┆ Half ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 495a-b6 ┆ Start ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 8a-19ca ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 1579... ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 9e5b064 ┆ GENERIC: ┆ null ┆ null ┆ ... ┆ null ┆ null ┆ null ┆ null │\n", + "│ 6-91cc- ┆ Half ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 49a1-bf ┆ Start ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 88-39bd ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ e773... ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ bbc398f ┆ PASS ┆ COMPLETE ┆ true ┆ ... ┆ 8963 ┆ KICK_OFF ┆ RIGHT_FOOT ┆ null │\n", + "│ 7-c784- ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 4958-a5 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 04-37b5 ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "│ 83ca... ┆ ┆ ┆ ┆ ┆ ┆ ┆ ┆ │\n", + "└─────────┴──────────┴──────────┴─────────┴─────┴────────────┴────────────┴────────────┴───────────┘" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# %pip install polars\n", + "# you might need to install polars\n", + "\n", + "df = dataset.to_df(\n", + " engine=\"polars\"\n", + ")\n", + "df.head()" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/kloppy/__init__.py b/kloppy/__init__.py index 2a7fa586..39d1652c 100644 --- a/kloppy/__init__.py +++ b/kloppy/__init__.py @@ -13,4 +13,4 @@ # ) # from .domain.services.state_builder import add_state -__version__ = "3.7.1" +__version__ = "3.8.0" diff --git a/mkdocs.yml b/mkdocs.yml index 68599b6a..72ac1cc6 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,4 @@ -site_name: kloppy 3.7.1 +site_name: kloppy 3.8.0 site_url: https://kloppy.pysport.org repo_url: https://github.com/PySport/kloppy repo_name: 'GitHub'