{ "cells": [ { "cell_type": "markdown", "id": "7100de70", "metadata": {}, "source": [ "1. Pobieranie bazy" ] }, { "cell_type": "code", "execution_count": 6, "id": "17518731", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Warning: Your Kaggle API key is readable by other users on this system! To fix this, you can run 'chmod 600 /home/osboxes/.kaggle/kaggle.json'\n", "Downloading extended-football-stats-for-european-leagues-xg.zip to /home/osboxes/jupyter_dir/notebooks/IUM03\n", " 73%|███████████████████████████▋ | 1.00M/1.37M [00:00<00:00, 5.12MB/s]\n", "100%|██████████████████████████████████████| 1.37M/1.37M [00:00<00:00, 3.95MB/s]\n" ] } ], "source": [ "!kaggle datasets download -d slehkyi/extended-football-stats-for-european-leagues-xg" ] }, { "cell_type": "code", "execution_count": 7, "id": "0d9abb90", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Archive: extended-football-stats-for-european-leagues-xg.zip\n", " inflating: understat.com.csv \n", " inflating: understat_per_game.csv \n" ] } ], "source": [ "!unzip -o extended-football-stats-for-european-leagues-xg.zip" ] }, { "cell_type": "markdown", "id": "edcb45ce", "metadata": {}, "source": [ "2. Zmiana nazwy plikow" ] }, { "cell_type": "code", "execution_count": 8, "id": "cb6595a3", "metadata": {}, "outputs": [], "source": [ "mv understat.com.csv understat.csv" ] }, { "cell_type": "markdown", "id": "b4aea8ec", "metadata": {}, "source": [ "3. Zmiana nazwy kolumn" ] }, { "cell_type": "code", "execution_count": 9, "id": "6c519048", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "understat = pd.read_csv('understat.csv')\n", "understat_per_game = pd.read_csv('understat_per_game.csv')" ] }, { "cell_type": "code", "execution_count": 18, "id": "fc730d10", "metadata": {}, "outputs": [], "source": [ "understat.rename( columns={'Unnamed: 0':'league'}, inplace=True)\n", "understat.rename( columns={'Unnamed: 1':'year'}, inplace=True)" ] }, { "cell_type": "code", "execution_count": 19, "id": "5b636526", "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", " \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", "
leagueyearpositionteammatcheswinsdrawslosesscoredmissed...xGAxGA_diffnpxGAnpxGDppda_coefoppda_coefdeepdeep_allowedxptsxpts_diff
0La_liga20141Barcelona38304411021...28.4442937.44429324.72790773.0493055.68353516.36759348911494.08130.0813
1La_liga20142Real Madrid38302611838...42.6071984.60719838.89080547.21309010.20908512.92951035115381.7489-10.2511
2La_liga20143Atletico Madrid3823966729...29.0691070.06910726.83927125.7487378.9820289.23709119712373.1353-4.8647
3La_liga20144Valencia38221157032...39.3925727.39257233.44647716.2575018.7098277.87022520317263.7068-13.2932
4La_liga20145Sevilla3823787145...47.8627422.86274241.91652920.1780708.2761489.47780530516867.3867-8.6133
\n", "

5 rows × 24 columns

\n", "
" ], "text/plain": [ " league year position team matches wins draws loses \\\n", "0 La_liga 2014 1 Barcelona 38 30 4 4 \n", "1 La_liga 2014 2 Real Madrid 38 30 2 6 \n", "2 La_liga 2014 3 Atletico Madrid 38 23 9 6 \n", "3 La_liga 2014 4 Valencia 38 22 11 5 \n", "4 La_liga 2014 5 Sevilla 38 23 7 8 \n", "\n", " scored missed ... xGA xGA_diff npxGA npxGD ppda_coef \\\n", "0 110 21 ... 28.444293 7.444293 24.727907 73.049305 5.683535 \n", "1 118 38 ... 42.607198 4.607198 38.890805 47.213090 10.209085 \n", "2 67 29 ... 29.069107 0.069107 26.839271 25.748737 8.982028 \n", "3 70 32 ... 39.392572 7.392572 33.446477 16.257501 8.709827 \n", "4 71 45 ... 47.862742 2.862742 41.916529 20.178070 8.276148 \n", "\n", " oppda_coef deep deep_allowed xpts xpts_diff \n", "0 16.367593 489 114 94.0813 0.0813 \n", "1 12.929510 351 153 81.7489 -10.2511 \n", "2 9.237091 197 123 73.1353 -4.8647 \n", "3 7.870225 203 172 63.7068 -13.2932 \n", "4 9.477805 305 168 67.3867 -8.6133 \n", "\n", "[5 rows x 24 columns]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "understat.head()" ] }, { "cell_type": "code", "execution_count": 21, "id": "cbf956d9", "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", " \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", "
leagueyearh_axGxGAnpxGnpxGAdeepdeep_allowedscored...ppda_coefppda_attppda_defoppda_coefoppda_attoppda_defteamxG_diffxGA_diffxpts_diff
0Bundesliga2014h2.570121.1984202.570121.198420542...9.6250002312421.85000043720Bayern Munich0.570120.198420-0.6514
1Bundesliga2014a1.503281.3079501.503281.3079501011...4.7560981954117.69565240723Bayern Munich0.503280.3079500.5143
2Bundesliga2014h1.229870.3101661.229870.3101661332...5.0606061673316.96153844126Bayern Munich-0.770130.310166-0.8412
3Bundesliga2014a1.035190.2031181.035190.203118620...4.423077115269.44680944447Bayern Munich1.035190.2031181.1367
4Bundesliga2014h3.482860.4028443.482860.4028442324...4.2500001704044.80000044810Bayern Munich-0.517140.402844-0.0713
\n", "

5 rows × 29 columns

\n", "
" ], "text/plain": [ " league year h_a xG xGA npxG npxGA deep \\\n", "0 Bundesliga 2014 h 2.57012 1.198420 2.57012 1.198420 5 \n", "1 Bundesliga 2014 a 1.50328 1.307950 1.50328 1.307950 10 \n", "2 Bundesliga 2014 h 1.22987 0.310166 1.22987 0.310166 13 \n", "3 Bundesliga 2014 a 1.03519 0.203118 1.03519 0.203118 6 \n", "4 Bundesliga 2014 h 3.48286 0.402844 3.48286 0.402844 23 \n", "\n", " deep_allowed scored ... ppda_coef ppda_att ppda_def oppda_coef \\\n", "0 4 2 ... 9.625000 231 24 21.850000 \n", "1 1 1 ... 4.756098 195 41 17.695652 \n", "2 3 2 ... 5.060606 167 33 16.961538 \n", "3 2 0 ... 4.423077 115 26 9.446809 \n", "4 2 4 ... 4.250000 170 40 44.800000 \n", "\n", " oppda_att oppda_def team xG_diff xGA_diff xpts_diff \n", "0 437 20 Bayern Munich 0.57012 0.198420 -0.6514 \n", "1 407 23 Bayern Munich 0.50328 0.307950 0.5143 \n", "2 441 26 Bayern Munich -0.77013 0.310166 -0.8412 \n", "3 444 47 Bayern Munich 1.03519 0.203118 1.1367 \n", "4 448 10 Bayern Munich -0.51714 0.402844 -0.0713 \n", "\n", "[5 rows x 29 columns]" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "understat_per_game.head()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }