{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "e621e3ae", "metadata": { "nbsphinx": "hidden" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "env: SOCCERDATA_LOGLEVEL=ERROR\n", "env: SOCCERDATA_NOCACHE=True\n", "env: SOCCERDATA_NOSTORE=True\n" ] } ], "source": [ "%env SOCCERDATA_LOGLEVEL=ERROR\n", "%env SOCCERDATA_NOCACHE=True\n", "%env SOCCERDATA_NOSTORE=True" ] }, { "cell_type": "code", "execution_count": 2, "id": "2454afe6", "metadata": {}, "outputs": [], "source": [ "import soccerdata as sd" ] }, { "cell_type": "markdown", "id": "b5784f2d", "metadata": {}, "source": [ "# ClubElo" ] }, { "cell_type": "code", "execution_count": 3, "id": "8dab5be9", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Provides pd.DataFrames from CSV API at http://api.clubelo.com.\n", "\n", " Data will be downloaded as necessary and cached locally in\n", " ``~/soccerdata/data/ClubElo``.\n", "\n", " Since the source does not provide league names, this class will not filter\n", " by league. League names will be inserted from the other sources where\n", " available. Leagues that are only covered by clubelo.com will have NaN\n", " values.\n", "\n", " Parameters\n", " ----------\n", " proxy : 'tor' or or dict or list(dict) or callable, optional\n", " Use a proxy to hide your IP address. Valid options are:\n", " - \"tor\": Uses the Tor network. Tor should be running in\n", " the background on port 9050.\n", " - dict: A dictionary with the proxy to use. The dict should be\n", " a mapping of supported protocols to proxy addresses. For example::\n", "\n", " {\n", " 'http': 'http://10.10.1.10:3128',\n", " 'https': 'http://10.10.1.10:1080',\n", " }\n", "\n", " - list(dict): A list of proxies to choose from. A different proxy will\n", " be selected from this list after failed requests, allowing rotating\n", " proxies.\n", " - callable: A function that returns a valid proxy. This function will\n", " be called after failed requests, allowing rotating proxies.\n", " no_cache : bool\n", " If True, will not use cached data.\n", " no_store : bool\n", " If True, will not store downloaded data.\n", " data_dir : Path\n", " Path to directory where data will be cached.\n", " \n" ] } ], "source": [ "elo = sd.ClubElo()\n", "print(elo.__doc__)" ] }, { "cell_type": "markdown", "id": "3a4c2916", "metadata": {}, "source": [ "## ELO scores for all teams at specified date" ] }, { "cell_type": "code", "execution_count": 4, "id": "745be31a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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", "
rankcountrylevelelofromtoleague
team
Liverpool1.0ENG12047.0838622022-04-202022-04-24ENG-Premier League
Man City2.0ENG12037.0599372022-04-212022-04-23ENG-Premier League
Bayern3.0GER11984.7753912022-04-182022-04-23GER-Bundesliga
Real Madrid4.0ESP11969.5843512022-04-212022-04-26ESP-La Liga
Chelsea5.0ENG11921.1014402022-04-212022-04-24ENG-Premier League
\n", "
" ], "text/plain": [ " rank country level elo from to \\\n", "team \n", "Liverpool 1.0 ENG 1 2047.083862 2022-04-20 2022-04-24 \n", "Man City 2.0 ENG 1 2037.059937 2022-04-21 2022-04-23 \n", "Bayern 3.0 GER 1 1984.775391 2022-04-18 2022-04-23 \n", "Real Madrid 4.0 ESP 1 1969.584351 2022-04-21 2022-04-26 \n", "Chelsea 5.0 ENG 1 1921.101440 2022-04-21 2022-04-24 \n", "\n", " league \n", "team \n", "Liverpool ENG-Premier League \n", "Man City ENG-Premier League \n", "Bayern GER-Bundesliga \n", "Real Madrid ESP-La Liga \n", "Chelsea ENG-Premier League " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "current_elo = elo.read_by_date()\n", "current_elo.head()" ] }, { "cell_type": "markdown", "id": "246ca661", "metadata": {}, "source": [ "## Full ELO history for one club" ] }, { "cell_type": "code", "execution_count": 5, "id": "1c87e14a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\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", "
rankteamcountryleveleloto
from
1939-10-22NaNBarcelonaESP11636.7045901939-12-03
1939-12-04NaNBarcelonaESP11626.1021731939-12-10
1939-12-11NaNBarcelonaESP11636.7282711939-12-17
1939-12-18NaNBarcelonaESP11646.9516601939-12-24
1939-12-25NaNBarcelonaESP11637.4243161939-12-31
\n", "
" ], "text/plain": [ " rank team country level elo to\n", "from \n", "1939-10-22 NaN Barcelona ESP 1 1636.704590 1939-12-03\n", "1939-12-04 NaN Barcelona ESP 1 1626.102173 1939-12-10\n", "1939-12-11 NaN Barcelona ESP 1 1636.728271 1939-12-17\n", "1939-12-18 NaN Barcelona ESP 1 1646.951660 1939-12-24\n", "1939-12-25 NaN Barcelona ESP 1 1637.424316 1939-12-31" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "barca_elo = elo.read_team_history(\"Barcelona\")\n", "barca_elo.head()" ] } ], "metadata": { "kernelspec": { "display_name": "soccerdata", "language": "python", "name": "soccerdata" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": true } }, "nbformat": 4, "nbformat_minor": 5 }