{
"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",
" rank | \n",
" country | \n",
" level | \n",
" elo | \n",
" from | \n",
" to | \n",
" league | \n",
"
\n",
" \n",
" team | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" Liverpool | \n",
" 1.0 | \n",
" ENG | \n",
" 1 | \n",
" 2047.083862 | \n",
" 2022-04-20 | \n",
" 2022-04-24 | \n",
" ENG-Premier League | \n",
"
\n",
" \n",
" Man City | \n",
" 2.0 | \n",
" ENG | \n",
" 1 | \n",
" 2037.059937 | \n",
" 2022-04-21 | \n",
" 2022-04-23 | \n",
" ENG-Premier League | \n",
"
\n",
" \n",
" Bayern | \n",
" 3.0 | \n",
" GER | \n",
" 1 | \n",
" 1984.775391 | \n",
" 2022-04-18 | \n",
" 2022-04-23 | \n",
" GER-Bundesliga | \n",
"
\n",
" \n",
" Real Madrid | \n",
" 4.0 | \n",
" ESP | \n",
" 1 | \n",
" 1969.584351 | \n",
" 2022-04-21 | \n",
" 2022-04-26 | \n",
" ESP-La Liga | \n",
"
\n",
" \n",
" Chelsea | \n",
" 5.0 | \n",
" ENG | \n",
" 1 | \n",
" 1921.101440 | \n",
" 2022-04-21 | \n",
" 2022-04-24 | \n",
" ENG-Premier League | \n",
"
\n",
" \n",
"
\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",
" rank | \n",
" team | \n",
" country | \n",
" level | \n",
" elo | \n",
" to | \n",
"
\n",
" \n",
" from | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" 1939-10-22 | \n",
" NaN | \n",
" Barcelona | \n",
" ESP | \n",
" 1 | \n",
" 1636.704590 | \n",
" 1939-12-03 | \n",
"
\n",
" \n",
" 1939-12-04 | \n",
" NaN | \n",
" Barcelona | \n",
" ESP | \n",
" 1 | \n",
" 1626.102173 | \n",
" 1939-12-10 | \n",
"
\n",
" \n",
" 1939-12-11 | \n",
" NaN | \n",
" Barcelona | \n",
" ESP | \n",
" 1 | \n",
" 1636.728271 | \n",
" 1939-12-17 | \n",
"
\n",
" \n",
" 1939-12-18 | \n",
" NaN | \n",
" Barcelona | \n",
" ESP | \n",
" 1 | \n",
" 1646.951660 | \n",
" 1939-12-24 | \n",
"
\n",
" \n",
" 1939-12-25 | \n",
" NaN | \n",
" Barcelona | \n",
" ESP | \n",
" 1 | \n",
" 1637.424316 | \n",
" 1939-12-31 | \n",
"
\n",
" \n",
"
\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
}