{"id":917,"date":"2019-09-11T17:37:19","date_gmt":"2019-09-11T15:37:19","guid":{"rendered":"http:\/\/35.180.88.53\/?p=917"},"modified":"2019-09-22T15:07:31","modified_gmt":"2019-09-22T13:07:31","slug":"football-why-winners-win-and-losers-loose","status":"publish","type":"post","link":"https:\/\/www.sergilehkyi.com\/uk\/2019\/09\/football-why-winners-win-and-losers-loose\/","title":{"rendered":"\u0424\u0443\u0442\u0431\u043e\u043b: \u0427\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u043c\u043e\u0436\u0446\u0456 \u043f\u0435\u0440\u0435\u043c\u0430\u0433\u0430\u044e\u0442\u044c, \u0430 \u043d\u0435\u0432\u0434\u0430\u0445\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u044e\u0442\u044c"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u0414\u0438\u0432\u0438\u043c\u043e\u0441\u044c 5 \u0440\u043e\u043a\u0456\u0432 \u0454\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u044c\u043a\u043e\u0433\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u0443<\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u0406\u043d\u0442\u0440\u043e<\/h2>\n\n\n\n<p>\u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456 \u043c\u0438 \u0432\u0438\u0432\u0447\u0438\u043c\u043e \u0441\u0443\u0447\u0430\u0441\u043d\u0456 \u043f\u043e\u043a\u0430\u0437\u043d\u0438\u043a\u0438 \u0443 \u0444\u0443\u0442\u0431\u043e\u043b\u0456 (xG, xGA \u0442\u0430 xPTS) \u0442\u0430 \u0457\u0445 \u0432\u043f\u043b\u0438\u0432 \u0443 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u0456\u0439 \u0430\u043d\u0430\u043b\u0456\u0442\u0438\u0446\u0456.<\/p>\n\n\n\n<ul><li><strong>\u041e\u0447\u0456\u043a\u0443\u0432\u0430\u043d\u0456 \u0433\u043e\u043b\u0438 (xG)<\/strong>&nbsp;\u2013 \u0432\u0438\u043c\u0456\u0440\u044e\u0454 \u044f\u043a\u0456\u0441\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u0456\u043b\u0443 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0456 \u0434\u0435\u043a\u0456\u043b\u044c\u043a\u043e\u0445 \u0437\u043c\u0456\u043d\u043d\u0438\u0445, \u0442\u0430\u043a\u0438\u0445 \u044f\u043a \u0442\u0438\u043f \u0430\u0441\u0438\u0441\u0442\u0443, \u043a\u0443\u0442 \u043f\u043e\u0441\u0442\u0440\u0456\u043b\u0443 \u0442\u0430 \u0432\u0456\u0434\u0441\u0442\u0430\u043d\u044c \u0432\u0456\u0434 \u0432\u043e\u0440\u0456\u0442, \u0447\u0438 \u0446\u0435 \u0431\u0443\u0432 \u0443\u0434\u0430\u0440 \u0433\u043e\u043b\u043e\u0432\u043e\u044e \u0442\u0430 \u0447\u0438 \u0432\u0438\u0437\u043d\u0430\u0447\u0430\u0432\u0441\u044f \u0432\u0456\u043d \u044f\u043a \u0432\u0435\u043b\u0438\u043a\u0438\u0439 \u0448\u0430\u043d\u0441.<\/li><li><strong>\u041e\u0447\u0456\u043a\u0443\u0432\u0430\u043d\u0456 \u0433\u043e\u043b\u044c\u043e\u0432\u0456 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0456 (xGA)<\/strong>&nbsp;\u2013 \u0432\u0438\u043c\u0456\u0440\u044e\u0454 \u0439\u043c\u043e\u0432\u0456\u0440\u043d\u0456\u0441\u0442\u044c \u0442\u043e\u0433\u043e, \u0449\u043e \u0434\u0430\u043d\u0438\u0439 \u043f\u0430\u0441 \u0441\u0442\u0430\u043d\u0435 \u0433\u043e\u043b\u044c\u043e\u0432\u0438\u043c. \u0412\u0456\u043d \u0432\u0440\u0430\u0445\u043e\u0432\u0443\u0454 \u043a\u0456\u043b\u044c\u043a\u0430 \u0444\u0430\u043a\u0442\u043e\u0440\u0456\u0432, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0447\u0438 \u0442\u0438\u043f \u043f\u0430\u0441\u0443, \u043a\u0456\u043d\u0446\u0435\u0432\u0443 \u0442\u043e\u0447\u043a\u0443 \u043f\u0430\u0441\u0443 \u0442\u0430 \u0439\u043e\u0433\u043e \u0434\u043e\u0432\u0436\u0438\u043d\u0443.<\/li><li><strong>\u041e\u0447\u0456\u043a\u0443\u0432\u0430\u043d\u0456 \u043e\u0447\u043a\u0438 (xPTS)<\/strong>&nbsp;\u2013 \u0432\u0438\u043c\u0456\u0440\u044e\u0454 \u0439\u043c\u043e\u0432\u0456\u0440\u043d\u0456\u0441\u0442\u044c \u043f\u0435\u0432\u043d\u043e\u0457 \u0433\u0440\u0438 \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438 \u043e\u0447\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0456.<\/li><\/ul>\n\n\n\n<p>\u0426\u0456 \u043f\u043e\u043a\u0430\u0437\u043d\u0438\u043a\u0438 \u0434\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442\u044c \u043d\u0430\u043c \u0437\u0430\u0433\u043b\u0438\u0431\u0438\u0442\u0438\u0441\u044c \u0443 \u0444\u0443\u0442\u0431\u043e\u043b\u044c\u043d\u0443 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0442\u0430 \u0437\u0440\u043e\u0437\u0443\u043c\u0456\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438 \u0440\u043e\u0431\u043e\u0442\u0438 \u0433\u0440\u0430\u0432\u0446\u0456\u0432 \u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434 \u0437\u0430\u0433\u0430\u043b\u043e\u043c \u0442\u0430 \u0443\u0441\u0432\u0456\u0434\u043e\u043c\u0438\u0442\u0438 \u0440\u043e\u043b\u044c \u0443\u0434\u0430\u0447\u0456 \u0442\u0430 \u043c\u0430\u0439\u0441\u0442\u0435\u0440\u043d\u043e\u0441\u0442\u0456 \u0432 \u043d\u0456\u0439. \u0421\u043f\u043e\u0439\u043b\u0435\u0440: \u0432\u043e\u043d\u0438 \u043e\u0431\u0438\u0434\u0432\u0456 \u0432\u0430\u0436\u043b\u0438\u0432\u0456.<\/p>\n\n\n\n<p>\u041f\u0440\u043e\u0446\u0435\u0441 \u0437\u0431\u043e\u0440\u0443 \u0434\u0430\u043d\u0438\u0445 \u0434\u043b\u044f \u0446\u0456\u0454\u0457 \u0441\u0442\u0430\u0442\u0442\u0456 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0443 \u0446\u044c\u043e\u043c\u0443 Kaggle kernel:&nbsp;<a href=\"https:\/\/www.kaggle.com\/slehkyi\/web-scraping-football-statistics-2014-now\">Web Scraping Football Statistics<\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport collections\nimport warnings\n\nfrom IPython.core.display import display, HTML\n\n<em># import plotly <\/em>\nimport plotly\nimport plotly.figure_factory as ff\nimport plotly.graph_objs as go\nimport plotly.offline as py\nfrom plotly.offline import iplot, init_notebook_mode\nimport plotly.tools as tls\n\n<em># configure things<\/em>\nwarnings.filterwarnings('ignore')\n\npd.options.display.float_format = '<strong>{:,.2f}<\/strong>'.format  \npd.options.display.max_columns = 999\n\npy.init_notebook_mode(connected=True)\n\n%load_ext autoreload\n%autoreload 2\n\n%matplotlib inline\nsns.set()\n\n<em># !pip install plotly --upgrade<\/em><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0406\u043c\u043f\u043e\u0440\u0442 \u0434\u0430\u043d\u0438\u0445 \u0442\u0430 \u0432\u0456\u0437\u0443\u0430\u043b\u044c\u043d\u0438\u0439 \u0430\u043d\u0430\u043b\u0456\u0437<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">df = pd.read_csv('..\/input\/understat.com.csv')\ndf = df.rename(index=int, columns={'Unnamed: 0': 'league', 'Unnamed: 1': 'year'}) \ndf.head()<\/pre>\n\n\n\n<p>\u0423 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0456\u0439 \u0432\u0456\u0437\u0443\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u0457 \u043c\u0438 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u043c\u043e, \u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u043a\u043e\u043c\u0430\u043d\u0434 \u0437 \u043a\u043e\u0436\u043d\u043e\u0457 \u043b\u0456\u0433\u0438 \u0431\u0443\u043b\u0438 \u0432 \u0442\u043e\u043f-4 \u0437\u0430 \u043e\u0441\u0442\u0430\u043d\u043d\u0456 5 \u0440\u043e\u043a\u0456\u0432. \u0426\u0435 \u043c\u043e\u0436\u0435 \u0434\u0430\u0442\u0438 \u043d\u0430\u043c \u0434\u0435\u044f\u043a\u0443 \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u044e \u043f\u0440\u043e \u0441\u0442\u0430\u0431\u0456\u043b\u044c\u043d\u0456\u0441\u0442\u044c \u043d\u0430\u0439\u043a\u0440\u0430\u0449\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0437 \u0440\u0456\u0437\u043d\u0438\u0445 \u043a\u0440\u0430\u0457\u043d.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">f = plt.figure(figsize=(25,12))\nax = f.add_subplot(2,3,1)\nplt.xticks(rotation=45)\nsns.barplot(x='team', y='pts', hue='year', data=df[(df['league'] == 'Bundesliga') & (df['position'] <= 4)], ax=ax)\nax = f.add_subplot(2,3,2)\nplt.xticks(rotation=45)\nsns.barplot(x='team', y='pts', hue='year', data=df[(df['league'] == 'EPL') &#038; (df['position'] <= 4)], ax=ax)\nax = f.add_subplot(2,3,3)\nplt.xticks(rotation=45)\nsns.barplot(x='team', y='pts', hue='year', data=df[(df['league'] == 'La_liga') &#038; (df['position'] <= 4)], ax=ax)\nax = f.add_subplot(2,3,4)\nplt.xticks(rotation=45)\nsns.barplot(x='team', y='pts', hue='year', data=df[(df['league'] == 'Serie_A') &#038; (df['position'] <= 4)], ax=ax)\nax = f.add_subplot(2,3,5)\nplt.xticks(rotation=45)\nsns.barplot(x='team', y='pts', hue='year', data=df[(df['league'] == 'Ligue_1') &#038; (df['position'] <= 4)], ax=ax)\nax = f.add_subplot(2,3,6)\nplt.xticks(rotation=45)\nsns.barplot(x='team', y='pts', hue='year', data=df[(df['league'] == 'RFPL') &#038; (df['position'] <= 4)], ax=ax)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"519\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_1024\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/league_data_1-1024x519.jpg\" alt=\"\" class=\"wp-image-918\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/league_data_1-1024x519.jpg 1024w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/league_data_1-300x152.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/league_data_1-768x389.jpg 768w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/league_data_1-1600x811.jpg 1600w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/league_data_1.jpg 1665w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u042f\u043a \u043c\u0438 \u0431\u0430\u0447\u0438\u043c\u043e \u0437 \u0446\u0438\u0445 \u0433\u0456\u0441\u0442\u043e\u043b\u043e\u0433\u0456\u0447\u043d\u0438\u0445 \u0434\u0456\u0430\u0433\u0440\u0430\u043c, \u0454 \u043a\u043e\u043c\u0430\u043d\u0434\u0438, \u044f\u043a\u0456 \u0437\u0430 \u043e\u0441\u0442\u0430\u043d\u043d\u0456 5 \u0440\u043e\u043a\u0456\u0432 \u0431\u0443\u043b\u0438 \u0432 \u0442\u043e\u043f-4 \u043b\u0438\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0454, \u0449\u043e \u0446\u0435 \u043d\u0435 \u0454 \u043d\u043e\u0440\u043c\u043e\u044e \u0434\u043b\u044f \u043d\u0438\u0445, \u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0454, \u0449\u043e \u044f\u043a\u0449\u043e \u043c\u0438 \u043a\u043e\u043f\u043d\u0435\u043c\u043e \u0433\u043b\u0438\u0431\u0448\u0435, \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u044f\u0432\u0438\u0442\u0438, \u0449\u043e \u0454 \u0444\u0430\u043a\u0442\u043e\u0440 \u0443\u0434\u0430\u0447\u0456, \u044f\u043a\u0438\u0439 \u043c\u043e\u0436\u043b\u0438\u0432\u043e, \u0437\u0456\u0433\u0440\u0430\u0432 \u043d\u0430 \u043a\u043e\u0440\u0438\u0441\u0442\u044c \u0446\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c. \u0426\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043e\u0440\u0456\u044f, \u0442\u043e\u0436 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0438\u0434\u0438\u0432\u0438\u043c\u043e\u0441\u044c \u0431\u043b\u0438\u0436\u0447\u0435 \u0434\u043e \u0446\u0438\u0445 \u0430\u043d\u043e\u043c\u0430\u043b\u0456\u0439.<\/p>\n\n\n\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0438, \u044f\u043a\u0456 \u043f\u043e\u0442\u0440\u0430\u043f\u0438\u043b\u0438 \u0443 \u0442\u043e\u043f-4 \u043b\u0438\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u043f\u0440\u043e\u0442\u044f\u0433\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u043d\u0456\u0445 5 \u0441\u0435\u0437\u043e\u043d\u0456\u0432:<\/p>\n\n\n\n<ul><li>\u0412\u043e\u043b\u044c\u0444\u0441\u0431\u0443\u0440\u0433 (2014) \u0456 \u0428\u0430\u043b\u044c\u043a\u0435 04 (2017) \u0437 \u0411\u0443\u043d\u0434\u0435\u0441\u043b\u0456\u0433\u0438<\/li><li>\u041b\u0435\u0441\u0442\u0435\u0440 (2015) \u0437 \u0410\u043d\u0433\u043b\u0456\u0439\u0441\u044c\u043a\u043e\u0457 \u041f\u0440\u0435\u043c'\u0454\u0440 \u041b\u0456\u0433\u0438<\/li><li>\u0412\u0456\u043b\u044c\u044f\u0440\u0435\u0430\u043b (2015) \u0456 \u0421\u0435\u0432\u0456\u043b\u044c\u044f (2016) \u0437 \u0406\u0441\u043f\u0430\u043d\u0441\u044c\u043a\u043e\u0457 \u041b\u0430 \u041b\u0456\u0433\u0438<\/li><li>\u041b\u0430\u0446\u0456\u043e (2014) \u0456 \u0424\u0456\u043e\u0440\u0435\u043d\u0442\u0438\u043d\u0430 (2014) \u0437 \u0406\u0442\u0430\u043b\u0456\u0439\u0441\u044c\u043a\u043e\u0457 \u0421\u0435\u0440\u0456\u0457 \u0410<\/li><li>\u041b\u0456\u043b\u044c (2018) \u0456 \u0421\u0435\u043d\u0442-\u0415\u0442\u044c\u0454\u043d (2018) \u0437 \u0424\u0440\u0430\u043d\u0446\u0443\u0437\u044c\u043a\u043e\u0457 \u041b\u0456\u0433\u0438 1<\/li><li>\u0424\u041a \u0420\u043e\u0441\u0442\u043e\u0432 (2015) \u0456 \u0414\u0438\u043d\u0430\u043c\u043e \u041c\u043e\u0441\u043a\u0432\u0430 (2014) \u0437 \u0420\u043e\u0441\u0456\u0439\u0441\u044c\u043a\u043e\u0457 \u041f\u0440\u0435\u043c'\u0454\u0440 \u041b\u0456\u0433\u0438<\/li><\/ul>\n\n\n\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0431\u0435\u0440\u0435\u0436\u0435\u043c\u043e \u0446\u0456 \u043a\u043e\u043c\u0430\u043d\u0434\u0438.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Removing unnecessary for our analysis columns <\/em>\ndf_xg = df[['league', 'year', 'position', 'team', 'scored', 'xG', 'xG_diff', 'missed', 'xGA', 'xGA_diff', 'pts', 'xpts', 'xpts_diff']]\n\noutlier_teams = ['Wolfsburg', 'Schalke 04', 'Leicester', 'Villareal', 'Sevilla', 'Lazio', 'Fiorentina', 'Lille', 'Saint-Etienne', 'FC Rostov', 'Dinamo Moscow']<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Checking if getting the first place requires fenomenal execution<\/em>\nfirst_place = df_xg[df_xg['position'] == 1]\n\n<em># Get list of leagues<\/em>\nleagues = df['league'].drop_duplicates()\nleagues = leagues.tolist()\n\n<em># Get list of years<\/em>\nyears = df['year'].drop_duplicates()\nyears = years.tolist()<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0417\u0440\u043e\u0437\u0443\u043c\u0456\u0442\u0438 \u044f\u043a \u043f\u0435\u0440\u0435\u043c\u043e\u0436\u0446\u0456 \u043f\u0435\u0440\u0435\u043c\u0430\u0433\u0430\u044e\u0442\u044c<\/h2>\n\n\n\n<p>\u0423 \u0446\u044c\u043e\u043c\u0443 \u0440\u043e\u0437\u0434\u0456\u043b\u0456 \u043c\u0438 \u0441\u043f\u0440\u043e\u0431\u0443\u0454\u043c\u043e \u0437\u043d\u0430\u0439\u0442\u0438 \u0434\u0435\u044f\u043a\u0456 \u0448\u0430\u0431\u043b\u043e\u043d\u0438, \u044f\u043a\u0456 \u043c\u043e\u0436\u0443\u0442\u044c \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u0442\u0438 \u043d\u0430\u043c \u0437\u0440\u043e\u0437\u0443\u043c\u0456\u0442\u0438, \u044f\u043a\u0438\u043c\u0438 \u0454 \u0456\u043d\u0433\u0440\u0435\u0434\u0456\u0454\u043d\u0442\u0438 \u0441\u0443\u043f\u0443 \u043f\u0435\u0440\u0435\u043c\u043e\u0433\u0438 :D. \u041f\u043e\u0447\u043d\u0435\u043c\u043e \u0437 \u0411\u0443\u043d\u0434\u0435\u0441\u043b\u0456\u0433\u0438.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u0411\u0443\u043d\u0434\u0435\u0441\u043b\u0456\u0433\u0430<\/h3>\n\n\n\n<p>\u0414\u0430\u043d\u0456 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u044f\u0445 \u0456 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0432 \u0447\u0430\u0440\u0442\u0430\u0445 \u0430\u043d\u0433\u043b\u0456\u0439\u0441\u044c\u043a\u043e\u044e, \u0442\u043e\u043c\u0443 \u0449\u043e \u043f\u0435\u0440\u0448\u043e\u0434\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0440\u043e\u0431\u043b\u0435\u043d\u043e \u0446\u0456\u0454\u044e \u043c\u043e\u0432\u043e\u044e \u0456 \u0437\u043c\u0456\u043d\u044e\u0432\u0430\u0442\u0438 \u0432\u0441\u0435 \u043f\u0456\u0434\u0440\u044f\u0434 \u0437\u0430\u0431\u0440\u0430\u043b\u043e \u0431 \u0437\u0430\u043d\u0430\u0434\u0442\u043e \u0431\u0430\u0433\u0430\u0442\u043e \u0447\u0430\u0441\u0443. \u0412\u0438\u0431\u0430\u0447\u0430\u044e\u0441\u044c \ud83d\ude41<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">first_place[first_place['league'] == 'Bundesliga']<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"795\" height=\"158\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_795\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/bundesliga_1.jpg\" alt=\"\" class=\"wp-image-919\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_1.jpg 795w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_1-300x60.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_1-768x153.jpg 768w\" sizes=\"(max-width: 795px) 100vw, 795px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">pts = go.Bar(x = years, y = first_place['pts'][first_place['league'] == 'Bundesliga'], name = 'PTS')\nxpts = go.Bar(x = years, y = first_place['xpts'][first_place['league'] == 'Bundesliga'], name = 'Expected PTS')\n\ndata = [pts, xpts]\n\nlayout = go.Layout(\n    barmode='group',\n    title=\"Comparing Actual and Expected Points for Winner Team in Bundesliga\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"Points\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"864\" height=\"513\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_864\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/bundesliga_xg_1.jpg\" alt=\"\" class=\"wp-image-920\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_xg_1.jpg 864w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_xg_1-300x178.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_xg_1-768x456.jpg 768w\" sizes=\"(max-width: 864px) 100vw, 864px\" \/><\/figure>\n\n\n\n<p>\u041f\u043e\u0434\u0438\u0432\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u044e \u0442\u0430 \u0434\u0456\u0430\u0433\u0440\u0430\u043c\u0443, \u043c\u0438 \u0431\u0430\u0447\u0438\u043c\u043e, \u0449\u043e \u0411\u0430\u0432\u0430\u0440\u0456\u044f \u0437 \u043a\u043e\u0436\u043d\u0438\u043c \u0440\u043e\u043a\u043e\u043c \u043e\u0442\u0440\u0438\u043c\u0443\u0454 \u0431\u0456\u043b\u044c\u0448\u0435 \u043e\u0447\u043e\u043a, \u043d\u0456\u0436 \u0432\u043e\u043d\u0438 \u043f\u043e\u0432\u0438\u043d\u043d\u0456 \u0431\u0443\u043b\u0438 \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438, \u0432\u043e\u043d\u0438 \u0437\u0430\u0431\u0438\u043b\u0438 \u0431\u0456\u043b\u044c\u0448\u0435 \u0433\u043e\u043b\u0456\u0432, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043d\u043e, \u0456 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043c\u0435\u043d\u0448\u0435, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043b\u043e\u0441\u044f (\u0437\u0430 \u0432\u0438\u043d\u044f\u0442\u043a\u043e\u043c 2018 \u0440\u043e\u043a\u0443, \u044f\u043a\u0438\u0439 \u0432\u0441\u0435-\u0440\u0456\u0432\u043d\u043e \u043d\u0435 \u043f\u043e\u0440\u0443\u0448\u0438\u0432 \u0457\u0445\u043d\u044c\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0443 \u0432\u0438\u0433\u0440\u0430\u0442\u0438 \u0441\u0435\u0437\u043e\u043d, \u0430\u043b\u0435 \u0446\u0435 \u0434\u0430\u0454 \u0434\u0435\u044f\u043a\u0456 \u043f\u0456\u0434\u043a\u0430\u0437\u043a\u0438, \u0449\u043e \u0411\u0430\u0432\u0430\u0440\u0456\u044f \u0437\u0456\u0433\u0440\u0430\u043b\u0430 \u0433\u0456\u0440\u0448\u0435 \u0446\u044c\u043e\u0433\u043e \u0440\u043e\u043a\u0443, \u0445\u043e\u0447\u0430 \u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u0438 \u043d\u0435 \u0441\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u043b\u0438\u0441\u044f \u0446\u0438\u043c).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># and from this table we see that Bayern dominates here totally, even when they do not play well<\/em>\ndf_xg[(df_xg['position'] <= 2) &#038; (df_xg['league'] == 'Bundesliga')].sort_values(by=['year','xpts'], ascending=False)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"837\" height=\"274\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_837\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/bundesliga_2.jpg\" alt=\"\" class=\"wp-image-921\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_2.jpg 837w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_2-300x98.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/bundesliga_2-768x251.jpg 768w\" sizes=\"(max-width: 837px) 100vw, 837px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u041b\u0430 \u041b\u0456\u0433\u0430<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">first_place[first_place['league'] == 'La_liga']<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"155\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_766\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/laliga_1.jpg\" alt=\"\" class=\"wp-image-922\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_1.jpg 766w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_1-300x61.jpg 300w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">pts = go.Bar(x = years, y = first_place['pts'][first_place['league'] == 'La_liga'], name = 'PTS')\nxpts = go.Bar(x = years, y = first_place['xpts'][first_place['league'] == 'La_liga'], name = 'Expected PTS')\n\ndata = [pts, xpts]\n\nlayout = go.Layout(\n    barmode='group',\n    title=\"Comparing Actual and Expected Points for Winner Team in La Liga\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"Points\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"843\" height=\"489\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_843\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/laliga_xg_1.jpg\" alt=\"\" class=\"wp-image-923\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_xg_1.jpg 843w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_xg_1-300x174.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_xg_1-768x445.jpg 768w\" sizes=\"(max-width: 843px) 100vw, 843px\" \/><\/figure>\n\n\n\n<p>\u042f\u043a \u043c\u0438 \u0431\u0430\u0447\u0438\u043c\u043e \u0437 \u0434\u0456\u0430\u0433\u0440\u0430\u043c\u0438 \u0432\u0438\u0449\u0435, \u0449\u043e \u0443 2014 \u0442\u0430 2015 \u0440\u043e\u043a\u0430\u0445 \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0430 \u0441\u0442\u0432\u043e\u0440\u044e\u0432\u0430\u043b\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043d\u044c\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0456\u0432, \u0449\u043e\u0431 \u0432\u0438\u0433\u0440\u0430\u0442\u0438 \u0442\u0438\u0442\u0443\u043b \u0456 \u043d\u0435 \u043f\u043e\u043a\u043b\u0430\u0434\u0430\u0442\u0438\u0441\u044f \u043d\u0430 \u043e\u0441\u043e\u0431\u0438\u0441\u0442\u0456 \u043d\u0430\u0432\u0438\u0447\u043a\u0438 \u0447\u0438 \u0443\u0434\u0430\u0447\u0443, \u0437 \u0446\u0438\u0445 \u0446\u0438\u0444\u0440 \u043d\u0430\u0441\u043f\u0440\u0430\u0432\u0434\u0456 \u043c\u043e\u0436\u043d\u0430 \u0441\u043a\u0430\u0437\u0430\u0442\u0438, \u0449\u043e \u0441\u043f\u0440\u0430\u0432\u0436\u043d\u044f \u041a\u041e\u041c\u0410\u041d\u0414\u0410 \u0433\u0440\u0430\u043b\u0430 \u0432 \u0442\u0456 \u0441\u0435\u0437\u043e\u043d\u0438.<\/p>\n\n\n\n<p>\u0423 2016 \u0440\u043e\u0446\u0456 \u043c\u0456\u0436 \u041c\u0430\u0434\u0440\u0438\u0434\u043e\u043c \u0442\u0430 \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u043e\u044e \u0431\u0443\u043b\u043e \u0431\u0430\u0433\u0430\u0442\u043e \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0456\u0457, \u0456 \u0432\u0440\u0435\u0448\u0442\u0456-\u0440\u0435\u0448\u0442 \u041c\u0430\u0434\u0440\u0438\u0434\u0443 \u043f\u043e\u0449\u0430\u0441\u0442\u0438\u043b\u043e \u0430\u0431\u043e \u043a\u043e\u0440\u043e\u043b\u0456\u0432\u0441\u044c\u043a\u0438\u0439 \u043a\u043b\u0443\u0431 \u043c\u0430\u0432 \u0431\u0456\u043b\u044c\u0448\u0456 \u044f\u0439\u0446\u044f \u0432 \u043e\u0434\u043d\u0456\u0439 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0456\u0439 \u0433\u0440\u0456 (\u0430\u0431\u043e \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0456 \u043d\u0435 \u043f\u043e\u0449\u0430\u0441\u0442\u0438\u043b\u043e \/ \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438 \u044f\u0439\u0446\u044f), \u0456 \u0446\u0435 \u0441\u0442\u0430\u043b\u043e \u0446\u0456\u043d\u043e\u044e \u0442\u0438\u0442\u0443\u043b\u0443. \u042f \u0432\u043f\u0435\u0432\u043d\u0435\u043d\u0438\u0439, \u0449\u043e \u044f\u043a\u0449\u043e \u043a\u043e\u043f\u043d\u0443\u0442\u0438 \u0433\u043b\u0438\u0431\u0448\u0435 \u0446\u0435\u0439 \u0441\u0435\u0437\u043e\u043d, \u043c\u0438 \u0437\u043c\u043e\u0436\u0435\u043c\u043e \u0437\u043d\u0430\u0439\u0442\u0438 \u0441\u0430\u043c\u0435 \u0446\u0435\u0439 \u043f\u043e\u0454\u0434\u0438\u043d\u043e\u043a.<\/p>\n\n\n\n<p>\u0423 2017 \u0442\u0430 2018 \u0440\u043e\u043a\u0430\u0445 \u0443\u0441\u043f\u0456\u0445 \"\u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0438\" \u0437\u0434\u0435\u0431\u0456\u043b\u044c\u0448\u043e\u0433\u043e \u0437\u0430\u0441\u043b\u0443\u0433\u0430 \u0434\u0456\u044f\u043c \u041b\u0456\u043e\u043d\u0435\u043b\u044f \u041c\u0435\u0441\u0441\u0456, \u044f\u043a\u0438\u0439 \u0437\u0430\u0431\u0438\u0432\u0430\u0432 \u0430\u0431\u043e \u0440\u043e\u0431\u0438\u0432 \u0433\u043e\u043b\u044c\u043e\u0432\u0456 \u043f\u0430\u0441\u0438 \u0432 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u044f\u0445, \u043a\u043e\u043b\u0438 \u0437\u0432\u0438\u0447\u0430\u0439\u043d\u0456 \u0433\u0440\u0430\u0432\u0446\u0456 \u0446\u044c\u043e\u0433\u043e \u0431 \u043d\u0435 \u0440\u043e\u0431\u0438\u043b\u0438. \u0429\u043e \u043f\u0440\u0438\u0437\u0432\u0435\u043b\u043e \u0434\u043e \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u0442\u0440\u0438\u0431\u043a\u0430 \u0432 \u0440\u0456\u0437\u043d\u0438\u0446\u0456 xPTS. \u0406 \u0446\u0435 \u0437\u043c\u0443\u0448\u0443\u0454 \u043c\u0435\u043d\u0435 \u0434\u0443\u043c\u0430\u0442\u0438 (\u043c\u0430\u044e\u0447\u0438 \u043d\u0430 \u0443\u0432\u0430\u0437\u0456, \u0449\u043e \"\u0420\u0435\u0430\u043b\" \u0432 \u0446\u044c\u043e\u043c\u0443 \u0441\u0435\u0437\u043e\u043d\u0456 \u0434\u0443\u0436\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u0438\u0439 \u043d\u0430 \u0442\u0440\u0430\u043d\u0441\u0444\u0435\u0440\u043d\u043e\u043c\u0443 \u0440\u0438\u043d\u043a\u0443), \u0449\u043e \u0432\u0441\u0435 \u043c\u043e\u0436\u0435 \u0437\u0430\u043a\u0456\u043d\u0447\u0438\u0442\u0438\u0441\u044f \u043f\u043e\u0433\u0430\u043d\u043e. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u0443\u0431'\u0454\u043a\u0442\u0438\u0432\u043d\u0430 \u0434\u0443\u043c\u043a\u0430, \u0437\u0430\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0447\u0438\u0441\u043b\u0430\u0445 \u0442\u0430 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u0434\u0456 \u043c\u0430\u0442\u0447\u0456\u0432 \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0438. \u0414\u0443\u0436\u0435 \u0441\u043f\u043e\u0434\u0456\u0432\u0430\u044e\u0441\u044f, \u0449\u043e \u044f \u043f\u043e\u043c\u0438\u043b\u044f\u044e\u0441\u044f.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># comparing with runner-up<\/em>\ndf_xg[(df_xg['position'] <= 2) &#038; (df_xg['league'] == 'La_liga')].sort_values(by=['year','xpts'], ascending=False)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"270\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_786\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/laliga_2.jpg\" alt=\"\" class=\"wp-image-924\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_2.jpg 786w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_2-300x103.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/laliga_2-768x264.jpg 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u0410\u041f\u041b<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">first_place[first_place['league'] == 'EPL']<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"789\" height=\"157\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_789\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/epl_1.jpg\" alt=\"\" class=\"wp-image-925\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_1.jpg 789w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_1-300x60.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_1-768x153.jpg 768w\" sizes=\"(max-width: 789px) 100vw, 789px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">pts = go.Bar(x = years, y = first_place['pts'][first_place['league'] == 'EPL'], name = 'PTS')\nxpts = go.Bar(x = years, y = first_place['xpts'][first_place['league'] == 'EPL'], name = 'Expected PTS')\n\ndata = [pts, xpts]\n\nlayout = go.Layout(\n    barmode='group',\n    title=\"Comparing Actual and Expected Points for Winner Team in EPL\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"Points\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"831\" height=\"490\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_831\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/epl_xg_1.jpg\" alt=\"\" class=\"wp-image-926\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_xg_1.jpg 831w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_xg_1-300x177.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_xg_1-768x453.jpg 768w\" sizes=\"(max-width: 831px) 100vw, 831px\" \/><\/figure>\n\n\n\n<p>\u0423 \u0410\u041f\u041b \u043c\u0438 \u0431\u0430\u0447\u0438\u043c\u043e \u0447\u0456\u0442\u043a\u0443 \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0456\u044e, \u044f\u043a\u0430 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0432\u0430\u043c: \"\u0429\u043e\u0431 \u043f\u0435\u0440\u0435\u043c\u043e\u0433\u0442\u0438, \u0442\u0438 \u043f\u043e\u0432\u0438\u043d\u0435\u043d \u0431\u0443\u0442\u0438 \u043a\u0440\u0430\u0449\u0438\u043c, \u043d\u0456\u0436 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430\". \u0426\u0456\u043a\u0430\u0432\u0438\u043c \u0432\u0438\u043f\u0430\u0434\u043a\u043e\u043c \u0454 \u0456\u0441\u0442\u043e\u0440\u0456\u044f \u041b\u0435\u0441\u0442\u0435\u0440\u0430 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u043e\u0437\u0456 \u0432 2015 \u0440\u043e\u0446\u0456: \u0432\u043e\u043d\u0438 \u043e\u0442\u0440\u0438\u043c\u0430\u043b\u0438 \u043d\u0430 12 \u043e\u0447\u043e\u043a \u0431\u0456\u043b\u044c\u0448\u0435, \u043d\u0456\u0436 \u043f\u043e\u0432\u0438\u043d\u043d\u0456 \u0431\u0443\u043b\u0438, \u0456 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0447\u0430\u0441 \u0410\u0440\u0441\u0435\u043d\u0430\u043b \u043d\u0435\u0434\u043e\u043e\u0442\u0440\u0438\u043c\u0430\u0432 6 \u043e\u0447\u043e\u043a! \u041e\u0441\u044c \u0447\u043e\u043c\u0443 \u043c\u0438 \u043b\u044e\u0431\u0438\u043c\u043e \u0444\u0443\u0442\u0431\u043e\u043b, \u0431\u043e \u0442\u0440\u0430\u043f\u043b\u044f\u044e\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u0456 \u043d\u0435\u0437\u0440\u043e\u0437\u0443\u043c\u0456\u043b\u0456 \u0440\u0435\u0447\u0456. \u042f \u043d\u0435 \u043a\u0430\u0436\u0443, \u0449\u043e \u0446\u0435 \u043f\u043e\u0432\u043d\u0456\u0441\u0442\u044e \u0443\u0434\u0430\u0447\u0430, \u0430\u043b\u0435 \u0432\u043e\u043d\u0430 \u0437\u0456\u0433\u0440\u0430\u043b\u0430 \u0442\u0443\u0442 \u0437\u043d\u0430\u0447\u043d\u0443 \u0440\u043e\u043b\u044c.<\/p>\n\n\n\n<p>\u0429\u0435 \u043e\u0434\u043d\u0430 \u0446\u0456\u043a\u0430\u0432\u0430 \u0440\u0456\u0447 - \u041c\u0430\u043d\u0447\u0435\u0441\u0442\u0435\u0440 \u0421\u0456\u0442\u0456 2018 \u0440\u043e\u043a\u0443 - \u0432\u043e\u043d\u0438 \u0441\u0443\u043f\u0435\u0440 \u0441\u0442\u0430\u0431\u0456\u043b\u044c\u043d\u0456! \u0412\u043e\u043d\u0438 \u0437\u0430\u0431\u0438\u043b\u0438 \u043b\u0438\u0448\u0435 \u043d\u0430 \u043e\u0434\u0438\u043d \u0433\u043e\u043b \u0431\u0456\u043b\u044c\u0448\u0435, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043b\u043e\u0441\u044f, \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b\u0438 \u043d\u0430 2 \u043c\u0435\u043d\u0448\u0435 \u0456 \u043e\u0442\u0440\u0438\u043c\u0430\u043b\u0438 7 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u0438\u0445 \u043e\u0447\u043e\u043a, \u0432 \u0442\u043e\u0439 \u0447\u0430\u0441 \u044f\u043a \u041b\u0456\u0432\u0435\u0440\u043f\u0443\u043b\u044c \u0431\u043e\u0440\u043e\u0432\u0441\u044f \u0434\u0443\u0436\u0435 \u0434\u043e\u0431\u0440\u0435, \u043c\u0430\u0432 \u0442\u0440\u043e\u0445\u0438 \u0431\u0456\u043b\u044c\u0448\u0435 \u0443\u0434\u0430\u0447\u0456 \u043d\u0430 \u0441\u0432\u043e\u0454\u043c\u0443 \u0431\u043e\u0446\u0456, \u0430\u043b\u0435 \u043d\u0435 \u0437\u043c\u0456\u0433 \u043f\u0435\u0440\u0435\u043c\u043e\u0433\u0442\u0438, \u043d\u0435\u0437\u0432\u0430\u0436\u0430\u044e\u0447\u0438 \u043d\u0430 13 \u043e\u0447\u043e\u043a \u0432\u0438\u043f\u0435\u0440\u0435\u0434\u0436\u0435\u043d\u043d\u044f \u043f\u043e  xPTS.<\/p>\n\n\n\n<p>\u041f\u0435\u043f \u0437\u0430\u043a\u0456\u043d\u0447\u0443\u0454 \u0431\u0443\u0434\u0456\u0432\u043d\u0438\u0446\u0442\u0432\u043e \u043c\u0430\u0448\u0438\u043d\u0438 \u0437\u043d\u0438\u0449\u0435\u043d\u043d\u044f. Man City \u0441\u0442\u0432\u043e\u0440\u044e\u0454 \u0442\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0443\u0454 \u0441\u0432\u043e\u0457 \u043c\u043e\u043c\u0435\u043d\u0442\u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0456 \u043c\u0430\u0439\u0441\u0442\u0435\u0440\u043d\u043e\u0441\u0442\u0456 \u0442\u0430 \u043d\u0435 \u043f\u043e\u043a\u043b\u0430\u0434\u0430\u0454\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0434\u0430\u0447\u0443 - \u0446\u0435 \u0440\u043e\u0431\u0438\u0442\u044c \u0457\u0445 \u0434\u0443\u0436\u0435 \u043d\u0435\u0431\u0435\u0437\u043f\u0435\u0447\u043d\u0438\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u0441\u0435\u0437\u043e\u043d\u0456.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># comparing with runner-ups<\/em>\ndf_xg[(df_xg['position'] <= 2) &#038; (df_xg['league'] == 'EPL')].sort_values(by=['year','xpts'], ascending=False)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"797\" height=\"266\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_797\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/epl_2.jpg\" alt=\"\" class=\"wp-image-927\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_2.jpg 797w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_2-300x100.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/epl_2-768x256.jpg 768w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u041b\u0456\u0433\u0430 1<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">first_place[first_place['league'] == 'Ligue_1']<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"152\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_806\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/ligue1_1.jpg\" alt=\"\" class=\"wp-image-928\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_1.jpg 806w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_1-300x57.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_1-768x145.jpg 768w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">pts = go.Bar(x = years, y = first_place['pts'][first_place['league'] == 'Ligue_1'], name = 'PTS')\nxpts = go.Bar(x = years, y = first_place['xpts'][first_place['league'] == 'Ligue_1'], name = 'Expected PTS')\n\ndata = [pts, xpts]\n\nlayout = go.Layout(\n    barmode='group',\n    title=\"Comparing Actual and Expected Points for Winner Team in Ligue 1\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"Points\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"829\" height=\"495\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_829\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/ligue1_xg_1.jpg\" alt=\"\" class=\"wp-image-929\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_xg_1.jpg 829w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_xg_1-300x179.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_xg_1-768x459.jpg 768w\" sizes=\"(max-width: 829px) 100vw, 829px\" \/><\/figure>\n\n\n\n<p>\u0423 \u0444\u0440\u0430\u043d\u0446\u0443\u0437\u044c\u043a\u0456\u0439 Ligue 1 \u043c\u0438 \u043f\u0440\u043e\u0434\u043e\u0432\u0436\u0443\u0454\u043c\u043e \u0441\u043f\u043e\u0441\u0442\u0435\u0440\u0456\u0433\u0430\u0442\u0438 \u0442\u0435\u043d\u0434\u0435\u043d\u0446\u0456\u044e: \"\u0429\u043e\u0431 \u0432\u0438\u0433\u0440\u0430\u0442\u0438, \u0442\u0438 \u043f\u043e\u0432\u0438\u043d\u0435\u043d \u0432\u0438\u043a\u043e\u043d\u0430\u0442\u0438 110%, \u0442\u043e\u043c\u0443 \u0449\u043e 100% \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043d\u044c\u043e\". \u0422\u0443\u0442 \u041f\u0430\u0440\u0456 \u0421\u0435\u043d \u0416\u0435\u0440\u043c\u0435\u043d \u043f\u043e\u0432\u043d\u0456\u0441\u0442\u044e \u0434\u043e\u043c\u0456\u043d\u0443\u0454. \u0422\u0456\u043b\u044c\u043a\u0438 \u0432 2016 \u0440\u043e\u0446\u0456 \u043c\u0438 \u043e\u0442\u0440\u0438\u043c\u0443\u0454\u043c\u043e \u0432\u0438\u043d\u044f\u0442\u043e\u043a \u0432 \u043e\u0441\u043e\u0431\u0456 \u041c\u043e\u043d\u0430\u043a\u043e, \u044f\u043a\u0438\u0439 \u0437\u0430\u0431\u0438\u0432 \u043d\u0430 30 \u0433\u043e\u043b\u0456\u0432 \u0431\u0456\u043b\u044c\u0448\u0435, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043b\u043e\u0441\u044f!!! \u0456 \u043e\u0442\u0440\u0438\u043c\u0430\u0432 \u043c\u0430\u0439\u0436\u0435 17 \u0431\u0430\u043b\u0456\u0432 \u0431\u0456\u043b\u044c\u0448\u0435, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043b\u043e\u0441\u044f! \u0423\u0434\u0430\u0447\u0430? \u0414\u043e\u0441\u0438\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0448\u043c\u0430\u0442\u043e\u043a. \u041f\u0421\u0416 \u0431\u0443\u0432 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0432 \u0442\u043e\u043c\u0443 \u0440\u043e\u0446\u0456, \u0430\u043b\u0435 \u041c\u043e\u043d\u0430\u043a\u043e \u0431\u0443\u0432 \u043d\u0430\u0434\u0437\u0432\u0438\u0447\u0430\u0439\u043d\u0438\u043c. \u0417\u043d\u043e\u0432\u0443 \u0436 \u0442\u0430\u043a\u0438, \u043c\u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u043c\u043e \u0441\u0442\u0432\u0435\u0440\u0434\u0436\u0443\u0432\u0430\u0442\u0438, \u0449\u043e \u0446\u0435 \u0447\u0438\u0441\u0442\u0430 \u0443\u0434\u0430\u0447\u0430 \u0447\u0438 \u0447\u0438\u0441\u0442\u0430 \u043c\u0430\u0439\u0441\u0442\u0435\u0440\u043d\u0456\u0441\u0442\u044c, \u0430 \u0446\u0435 \u0456\u0434\u0435\u0430\u043b\u044c\u043d\u0435 \u043f\u043e\u0454\u0434\u043d\u0430\u043d\u043d\u044f \u043e\u0431\u043e\u0445 \u0443 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e\u043c\u0443 \u043c\u0456\u0441\u0446\u0456 \u0432 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u0438\u0439 \u0447\u0430\u0441.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># comparing with runner-ups<\/em>\ndf_xg[(df_xg['position'] <= 2) &#038; (df_xg['league'] == 'Ligue_1')].sort_values(by=['year','xpts'], ascending=False)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"806\" height=\"265\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_806\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/ligue1_2.jpg\" alt=\"\" class=\"wp-image-930\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_2.jpg 806w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_2-300x99.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/ligue1_2-768x253.jpg 768w\" sizes=\"(max-width: 806px) 100vw, 806px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u0421\u0435\u0440\u0456\u044f \u0410<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">first_place[first_place['league'] == 'Serie_A']<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"150\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_749\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/serie_a_1.jpg\" alt=\"\" class=\"wp-image-931\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_1.jpg 749w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_1-300x60.jpg 300w\" sizes=\"(max-width: 749px) 100vw, 749px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">pts = go.Bar(x = years, y = first_place['pts'][first_place['league'] == 'Serie_A'], name = 'PTS')\nxpts = go.Bar(x = years, y = first_place['xpts'][first_place['league'] == 'Serie_A'], name = 'Expecetd PTS')\n\ndata = [pts, xpts]\n\nlayout = go.Layout(\n    barmode='group',\n    title=\"Comparing Actual and Expected Points for Winner Team in Serie A\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"Points\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"832\" height=\"500\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_832\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/serie_a_xg_1.jpg\" alt=\"\" class=\"wp-image-934\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_xg_1.jpg 832w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_xg_1-300x180.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_xg_1-768x462.jpg 768w\" sizes=\"(max-width: 832px) 100vw, 832px\" \/><\/figure>\n\n\n\n<p>\u0412 \u0456\u0442\u0430\u043b\u0456\u0439\u0441\u044c\u043a\u0456\u0439 \u0421\u0435\u0440\u0456\u0457 \u0410 \"\u042e\u0432\u0435\u043d\u0442\u0443\u0441\" \u0434\u043e\u043c\u0456\u043d\u0443\u0454 8 \u0440\u043e\u043a\u0456\u0432 \u043f\u043e\u0441\u043f\u0456\u043b\u044c, \u0445\u043e\u0447\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435 \u0434\u043e\u0441\u044f\u0433\u0442\u0438 \u0432\u0435\u043b\u0438\u043a\u0438\u0445 \u0443\u0441\u043f\u0456\u0445\u0456\u0432 \u0443 \u041b\u0456\u0437\u0456 \u0447\u0435\u043c\u043f\u0456\u043e\u043d\u0456\u0432. \u042f \u0434\u0443\u043c\u0430\u044e, \u0433\u043b\u044f\u043d\u0443\u0432\u0448\u0438 \u043d\u0430 \u0446\u044e \u0434\u0456\u0430\u0433\u0440\u0430\u043c\u0443 \u0442\u0430 \u0446\u0438\u0444\u0440\u0438, \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0437\u0440\u043e\u0437\u0443\u043c\u0456\u0442\u0438, \u0449\u043e \u042e\u0432\u0435 \u043d\u0435 \u043c\u0430\u0454 \u0434\u043e\u0441\u0442\u0430\u0442\u043d\u044c\u043e \u0441\u0438\u043b\u044c\u043d\u043e\u0457 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0446\u0456\u0457 \u0432\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0456 \u043a\u0440\u0430\u0457\u043d\u0438 \u0456 \u043e\u0442\u0440\u0438\u043c\u0443\u0454 \u0431\u0430\u0433\u0430\u0442\u043e \"\u0445\u0430\u043b\u044f\u0432\u043d\u0438\u0445\" \u043e\u0447\u043e\u043a, \u0449\u043e \u0437\u043d\u043e\u0432\u0443 \u0436 \u0442\u0430\u043a\u0438 \u0432\u0438\u043f\u043b\u0438\u0432\u0430\u0454 \u0437 \u0431\u0430\u0433\u0430\u0442\u044c\u043e\u0445 \u0444\u0430\u043a\u0442\u043e\u0440\u0456\u0432, \u0456 \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0438, \u0449\u043e \u041d\u0430\u043f\u043e\u043b\u0456 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0438 \u0432\u0438\u043f\u0435\u0440\u0435\u0434\u0436\u0430\u0432 \"\u042e\u0432\u0435\u043d\u0442\u0443\u0441\" \u043f\u043e \u043f\u043e\u043a\u0430\u0437\u043d\u0438\u043a\u0443 xPTS, \u0430\u043b\u0435 \u0446\u0435 \u0441\u043f\u0440\u0430\u0432\u0436\u043d\u0454 \u0436\u0438\u0442\u0442\u044f, \u0456, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, 2017 \u0440\u043e\u043a\u0443, \u042e\u0432\u0435 \u0431\u0443\u0432 \u0431\u043e\u0436\u0435\u0432\u0456\u043b\u044c\u043d\u0438\u043c \u0456 \u0437\u0430\u0431\u0438\u0432 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u0456 26 \u0433\u043e\u043b\u0456\u0432 (\u0430\u0431\u043e \u0441\u0442\u0432\u043e\u0440\u0438\u0432 \u0433\u043e\u043b\u0438 \u0437 \u043d\u0456\u0437\u0432\u0456\u0434\u043a\u0438), \u0430 \u041d\u0430\u043f\u043e\u043b\u0456 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0432 \u043d\u0430 3 \u0431\u0456\u043b\u044c\u0448\u0435, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043b\u043e\u0441\u044f (\u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043c\u0438\u043b\u043a\u0443 \u0432\u043e\u0440\u043e\u0442\u0430\u0440\u044f \u0447\u0438, \u043c\u043e\u0436\u043b\u0438\u0432\u043e, \u043f\u0435\u0440\u0435\u0432\u0430\u0433\u0443 \u044f\u043a\u043e\u0457\u0441\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0438 \u0432 1 \u0430\u0431\u043e 2 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0438\u0445 \u0441\u043f\u0430\u0440\u0438\u043d\u0433\u0430\u0445). \u042f\u043a \u0456 \u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u0457 \u0432 \u041b\u0430 \u041b\u0456\u0437\u0456, \u043a\u043e\u043b\u0438 \u0420\u0435\u0430\u043b \u041c\u0430\u0434\u0440\u0438\u0434 \u0441\u0442\u0430\u0432 \u0447\u0435\u043c\u043f\u0456\u043e\u043d\u043e\u043c, \u044f \u0432\u043f\u0435\u0432\u043d\u0435\u043d\u0438\u0439, \u0449\u043e \u043c\u0438 \u0437\u043c\u043e\u0436\u0435\u043c\u043e \u0437\u043d\u0430\u0439\u0442\u0438 1 \u0430\u0431\u043e 2 \u0433\u0440\u0438, \u044f\u043a\u0456 \u0431\u0443\u043b\u0438 \u043a\u043b\u044e\u0447\u043e\u0432\u0438\u043c\u0438 \u0432 \u0442\u043e\u043c\u0443 \u0440\u043e\u0446\u0456.<\/p>\n\n\n\n<p>\u0414\u0435\u0442\u0430\u043b\u0456 \u043c\u0430\u044e\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0443 \u0444\u0443\u0442\u0431\u043e\u043b\u0456. \u0420\u043e\u0437\u0443\u043c\u0456\u0454\u0442\u0435, \u043e\u0434\u043d\u0430 \u043f\u043e\u043c\u0438\u043b\u043a\u0430 \u0442\u0443\u0442, \u043e\u0434\u043d\u0430 \u0448\u0442\u0430\u043d\u0433\u0430 \u0442\u0430\u043c, \u0456 \u0432\u0438 \u0432\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u0437\u0432\u0430\u043d\u043d\u044f \u0447\u0435\u043c\u043f\u0456\u043e\u043d\u0430 \u043a\u0440\u0430\u0457\u043d\u0438.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># comparing to runner-ups<\/em>\ndf_xg[(df_xg['position'] <= 2) &#038; (df_xg['league'] == 'Serie_A')].sort_values(by=['year','xpts'], ascending=False)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"270\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_749\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/serie_a_2.jpg\" alt=\"\" class=\"wp-image-935\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_2.jpg 749w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/serie_a_2-300x108.jpg 300w\" sizes=\"(max-width: 749px) 100vw, 749px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u0420\u0424\u041f\u041b<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">first_place[first_place['league'] == 'RFPL']<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"797\" height=\"154\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_797\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/rfpl_1.jpg\" alt=\"\" class=\"wp-image-936\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_1.jpg 797w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_1-300x58.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_1-768x148.jpg 768w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">pts = go.Bar(x = years, y = first_place['pts'][first_place['league'] == 'RFPL'], name = 'PTS')\nxpts = go.Bar(x = years, y = first_place['xpts'][first_place['league'] == 'RFPL'], name = 'Expected PTS')\n\ndata = [pts, xpts]\n\nlayout = go.Layout(\n    barmode='group',\n    title=\"Comparing Actual and Expected Points for Winner Team in RFPL\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"Points\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"491\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_833\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/rfpl_xg.jpg\" alt=\"\" class=\"wp-image-937\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_xg.jpg 833w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_xg-300x177.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_xg-768x453.jpg 768w\" sizes=\"(max-width: 833px) 100vw, 833px\" \/><\/figure>\n\n\n\n<p>\u042f \u043d\u0435 \u0441\u043b\u0456\u0434\u043a\u0443\u044e \u0437\u0430 \u0440\u043e\u0441\u0456\u0439\u0441\u044c\u043a\u043e\u044e \u041f\u0440\u0435\u043c'\u0454\u0440-\u043b\u0456\u0433\u043e\u044e, \u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0445\u043e\u043b\u043e\u0434\u043d\u043e \u0434\u0438\u0432\u043b\u044f\u0447\u0438\u0441\u044c \u043d\u0430 \u0434\u0430\u043d\u0456, \u043c\u0438 \u0431\u0430\u0447\u0438\u043c\u043e \u0442\u0443 \u0441\u0430\u043c\u0443 \u0441\u0445\u0435\u043c\u0443, - \u0437\u0430\u0431\u0438\u0432\u0430\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435, \u043d\u0456\u0436 \u0442\u0438 \u0437\u0430\u0441\u043b\u0443\u0433\u043e\u0432\u0443\u0454\u0448, \u0430 \u0442\u0430\u043a\u043e\u0436 \u0446\u0456\u043a\u0430\u0432\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u044f \u0437 \u043c\u043e\u0441\u043a\u043e\u0432\u0441\u044c\u043a\u0438\u043c \u0426\u0421\u041a\u0410 \u0437 2015 \u043f\u043e 2017 \u0440\u0456\u043a. \u0417\u0430 \u0446\u0456 \u0440\u043e\u043a\u0438 \u0446\u0456 \u0445\u043b\u043e\u043f\u0446\u0456 \u0431\u0443\u043b\u0438 \u0445\u043e\u0440\u043e\u0448\u0456, \u0430\u043b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0443\u0432\u0430\u043b\u0438 \u0441\u0432\u043e\u0457 \u043f\u0435\u0440\u0435\u0432\u0430\u0433\u0438 \u043b\u0438\u0448\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0456\u043d\u0448\u0456 \u0434\u0432\u0430 - \u044f\u043a\u0449\u043e \u0432\u0438 \u043d\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0443\u0454\u0442\u0435, \u0432\u0430\u0441 \u043a\u0430\u0440\u0430\u044e\u0442\u044c, \u0430\u0431\u043e \u0432\u0430\u0448 \u0433\u043e\u043b\u043e\u0432\u043d\u0438\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0431\u0438\u0432\u0430\u0454 \u0431\u0456\u043b\u044c\u0448\u0435.<\/p>\n\n\n\n<p>\u0423 \u0444\u0443\u0442\u0431\u043e\u043b\u0456 \u043d\u0435\u043c\u0430\u0454 \u0441\u043f\u0440\u0430\u0432\u0435\u0434\u043b\u0438\u0432\u043e\u0441\u0442\u0456 :D. \u0425\u043e\u0447\u0430, \u044f \u0432\u0432\u0430\u0436\u0430\u044e, \u0449\u043e \u0437 VAR \u0446\u0438\u0444\u0440\u0438 \u0441\u0442\u0430\u043d\u0443\u0442\u044c \u0441\u0442\u0430\u0431\u0456\u043b\u044c\u043d\u0456\u0448\u0438\u043c\u0438 \u0432 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0456 \u0441\u0435\u0437\u043e\u043d\u0438. \u0422\u043e\u043c\u0443 \u0449\u043e \u043e\u0434\u043d\u0456\u0454\u044e \u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u0446\u0438\u0445 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u0438\u0445 \u0433\u043e\u043b\u0456\u0432 \u0442\u0430 \u043e\u0447\u043e\u043a \u0454 \u043f\u043e\u043c\u0438\u043b\u043a\u0438 \u0430\u0440\u0431\u0456\u0442\u0440\u0456\u0432.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># comparing to runner-ups<\/em>\ndf_xg[(df_xg['position'] <= 2) &#038; (df_xg['league'] == 'RFPL')].sort_values(by=['year','xpts'], ascending=False)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"270\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_800\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/rfpl_2.jpg\" alt=\"\" class=\"wp-image-938\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_2.jpg 800w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_2-300x101.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/rfpl_2-768x259.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u0421\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u043d\u0438\u0439 \u043e\u0433\u043b\u044f\u0434<\/h2>\n\n\n\n<p>\u041e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0454 6 \u043b\u0456\u0433 \u0437 \u0440\u0456\u0437\u043d\u0438\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0442\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u043e\u044e, \u044f \u0432\u0438\u0440\u0456\u0448\u0438\u0432 \u0437\u043e\u0441\u0435\u0440\u0435\u0434\u0438\u0442\u0438\u0441\u044c \u043d\u0430 \u043e\u0434\u043d\u0456\u0439 \u0434\u043b\u044f \u043f\u043e\u0447\u0430\u0442\u043a\u0443, \u0449\u043e\u0431 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u0442\u0438 \u0440\u0456\u0437\u043d\u0456 \u043f\u0456\u0434\u0445\u043e\u0434\u0438, \u0430 \u043f\u043e\u0442\u0456\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u0442\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0443 \u043c\u043e\u0434\u0435\u043b\u044c \u0430\u043d\u0430\u043b\u0456\u0437\u0443 \u043d\u0430 \u0456\u043d\u0448\u0456 5. \u0406, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u044f \u0434\u0438\u0432\u043b\u044e\u0441\u044f \u043f\u0435\u0440\u0435\u0432\u0430\u0436\u043d\u043e \u041b\u0430 \u041b\u0456\u0433\u0443, \u044f \u043f\u043e\u0447\u043d\u0443 \u0437 \u0446\u044c\u043e\u0433\u043e \u0437\u043c\u0430\u0433\u0430\u043d\u043d\u044f,\u0442\u0430\u043a \u044f\u043a \u044f \u0437\u043d\u0430\u044e \u043d\u0430\u0439\u0431\u0456\u043b\u044c\u0448\u0435 \u043f\u0440\u043e \u043d\u044c\u043e\u0433\u043e.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Creating separate DataFrames per each league<\/em>\nlaliga = df_xg[df_xg['league'] == 'La_liga']\nlaliga.reset_index(inplace=True)\nepl = df_xg[df_xg['league'] == 'EPL']\nepl.reset_index(inplace=True)\nbundesliga = df_xg[df_xg['league'] == 'Bundesliga']\nbundesliga.reset_index(inplace=True)\nseriea = df_xg[df_xg['league'] == 'Serie_A']\nseriea.reset_index(inplace=True)\nligue1 = df_xg[df_xg['league'] == 'Ligue_1']\nligue1.reset_index(inplace=True)\nrfpl = df_xg[df_xg['league'] == 'RFPL']\nrfpl.reset_index(inplace=True)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">laliga.describe()<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"743\" height=\"216\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_743\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/describe_1.jpg\" alt=\"\" class=\"wp-image-939\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/describe_1.jpg 743w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/describe_1-300x87.jpg 300w\" sizes=\"(max-width: 743px) 100vw, 743px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">def print_records_antirecords(df):\n  print('Presenting some records and antirecords: <strong>n<\/strong>')\n  for col <strong>in<\/strong> df.describe().columns:\n    if col <strong>not<\/strong> <strong>in<\/strong> ['index', 'year', 'position']:\n      team_min = df['team'].loc[df[col] == df.describe().loc['min',col]].values[0]\n      year_min = df['year'].loc[df[col] == df.describe().loc['min',col]].values[0]\n      team_max = df['team'].loc[df[col] == df.describe().loc['max',col]].values[0]\n      year_max = df['year'].loc[df[col] == df.describe().loc['max',col]].values[0]\n      val_min = df.describe().loc['min',col]\n      val_max = df.describe().loc['max',col]\n      print('The lowest value of <strong>{0}<\/strong> had <strong>{1}<\/strong> in <strong>{2}<\/strong> and it is equal to <strong>{3:.2f}<\/strong>'.format(col.upper(), team_min, year_min, val_min))\n      print('The highest value of <strong>{0}<\/strong> had <strong>{1}<\/strong> in <strong>{2}<\/strong> and it is equal to <strong>{3:.2f}<\/strong>'.format(col.upper(), team_max, year_max, val_max))\n      print('='*100)\n      \n<em># replace laliga with any league you want<\/em>\nprint_records_antirecords(laliga)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044f \u0434\u0435\u044f\u043a\u0438\u0445 \u0440\u0435\u043a\u043e\u0440\u0434\u0456\u0432 \u0442\u0430 \u0430\u043d\u0442\u0438\u0440\u0435\u043a\u043e\u0440\u0434\u0456\u0432:\n \u041d\u0430\u0439\u043d\u0438\u0436\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f\u043c SCORED \u0443 \u041a\u043e\u0440\u0434\u043e\u0431\u0438 \u0443 2014 \u0440\u043e\u0446\u0456 \u0431\u0443\u043b\u043e 22,00\n \u041d\u0430\u0439\u0432\u0438\u0449\u0443 \u0446\u0456\u043d\u043d\u0456\u0441\u0442\u044c SCORED \u043c\u0430\u0432 \u0420\u0435\u0430\u043b \u041c\u0430\u0434\u0440\u0438\u0434 \u0443 2014 \u0440\u043e\u0446\u0456 \u0456 \u0432\u0456\u043d \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 118,00\n ===================================================== ===============\n \u041d\u0430\u0439\u043c\u0435\u043d\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XG \u0431\u0443\u043b\u043e \u0443 \u0415\u0439\u0431\u0430\u0440\u0430 \u0443 2014 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 29,56\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XG \u043c\u0430\u043b\u0430 \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0430 \u0443 2015 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 113,60\n ===================================================== ===============\n \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0430 \u0443 2016 \u0440\u043e\u0446\u0456 \u043c\u0430\u043b\u0430 \u043d\u0430\u0439\u043c\u0435\u043d\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XG_DIFF \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 -22,45\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XG_DIFF \u043c\u0430\u0432 \u041b\u0430\u0441-\u041f\u0430\u043b\u044c\u043c\u0430\u0441 \u0443 2017 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 13,88\n ===================================================== ===============\n \u041d\u0430\u0439\u043d\u0438\u0436\u0447\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u043d\u0438\u043a MISSED \u043c\u0430\u0432 Atletico Madrid \u0432 2015 \u0440\u043e\u0446\u0456 \u0456 \u0432\u0456\u043d \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 18.00\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f MISSED \u043c\u0430\u043b\u0430 \u041e\u0441\u0430\u0441\u0443\u043d\u0430 \u0432 2016 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 94,00\n ===================================================== ===============\n \u041d\u0430\u0439\u043c\u0435\u043d\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XGA \u0431\u0443\u043b\u043e \u0432 Atletico Madrid \u0432 2015 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 27,80\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XGA \u043c\u0430\u0432 Levante \u0443 2018 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 78,86\n ===================================================== ===============\n \u041d\u0430\u0439\u043d\u0438\u0436\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f\u043c XGA_DIFF \u0431\u0443\u043b\u0430 \u041e\u0441\u0430\u0441\u0443\u043d\u0430 \u0432 2016 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u0430 \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 -29,18\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XGA_DIFF \u043c\u0430\u043b\u0430 \u0412\u0430\u043b\u0435\u043d\u0441\u0456\u044f \u0432 2015 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 13,69\n ===================================================== ===============\n \u041d\u0430\u0439\u043c\u0435\u043d\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f PTS \u0431\u0443\u043b\u043e \u0443 \u041a\u043e\u0440\u0434\u043e\u0431\u0438 \u0443 2014 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 20,00\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f PTS \u0443 \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0456 \u0431\u0443\u043b\u043e \u0443 2014 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 94,00\n ===================================================== ===============\n \u041d\u0430\u0439\u043d\u0438\u0436\u0447\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XPTS \u0431\u0443\u043b\u043e \u0432 \u0413\u0440\u0430\u043d\u0430\u0434\u0456 \u0432 2016 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 26,50\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XPTS \u043c\u0430\u043b\u0438 \u0411\u0430\u0440\u0441\u0435\u043b\u043e\u043d\u0430 \u0443 2015 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 94,38\n ===================================================== ===============\n \u041d\u0430\u0439\u043d\u0438\u0436\u0447\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u043d\u0438\u043a XPTS_DIFF \u043c\u0430\u0432 Atletico Madrid \u0432 2017 \u0440\u043e\u0446\u0456 \u0456 \u0432\u0456\u043d \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 -17,40\n \u041d\u0430\u0439\u0432\u0438\u0449\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f XPTS_DIFF \u043c\u0430\u043b\u0438 Deportivo La Coruna \u0443 2017 \u0440\u043e\u0446\u0456 \u0456 \u0432\u043e\u043d\u043e \u0434\u043e\u0440\u0456\u0432\u043d\u044e\u0454 20,16<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">trace0 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2014], \n    y = laliga['xG_diff'][laliga['year'] == 2014],\n    name = '2014',\n    mode = 'lines+markers'\n)\n\ntrace1 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2015], \n    y = laliga['xG_diff'][laliga['year'] == 2015],\n    name='2015',\n    mode = 'lines+markers'\n)\n\ntrace2 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2016], \n    y = laliga['xG_diff'][laliga['year'] == 2016],\n    name='2016',\n    mode = 'lines+markers'\n)\n\ntrace3 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2017], \n    y = laliga['xG_diff'][laliga['year'] == 2017],\n    name='2017',\n    mode = 'lines+markers'\n)\n\ntrace4 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2018], \n    y = laliga['xG_diff'][laliga['year'] == 2018],\n    name='2018',\n    mode = 'lines+markers'\n)\n\ndata = [trace0, trace1, trace2, trace3, trace4]\n\nlayout = go.Layout(\n    title=\"Comparing xG gap between positions\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"xG difference\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"450\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_700\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/xg_gap_1.png\" alt=\"\" class=\"wp-image-940\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/xg_gap_1.png 700w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/xg_gap_1-300x193.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">trace0 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2014], \n    y = laliga['xGA_diff'][laliga['year'] == 2014],\n    name = '2014',\n    mode = 'lines+markers'\n)\n\ntrace1 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2015], \n    y = laliga['xGA_diff'][laliga['year'] == 2015],\n    name='2015',\n    mode = 'lines+markers'\n)\n\ntrace2 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2016], \n    y = laliga['xGA_diff'][laliga['year'] == 2016],\n    name='2016',\n    mode = 'lines+markers'\n)\n\ntrace3 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2017], \n    y = laliga['xGA_diff'][laliga['year'] == 2017],\n    name='2017',\n    mode = 'lines+markers'\n)\n\ntrace4 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2018], \n    y = laliga['xGA_diff'][laliga['year'] == 2018],\n    name='2018',\n    mode = 'lines+markers'\n)\n\ndata = [trace0, trace1, trace2, trace3, trace4]\n\nlayout = go.Layout(\n    title=\"Comparing xGA gap between positions\",\n    xaxis={'title': 'Year'},\n    yaxis={'title': \"xGA difference\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"450\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_700\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/xga_gap.png\" alt=\"\" class=\"wp-image-941\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/xga_gap.png 700w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/xga_gap-300x193.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\">trace0 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2014], \n    y = laliga['xpts_diff'][laliga['year'] == 2014],\n    name = '2014',\n    mode = 'lines+markers'\n)\n\ntrace1 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2015], \n    y = laliga['xpts_diff'][laliga['year'] == 2015],\n    name='2015',\n    mode = 'lines+markers'\n)\n\ntrace2 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2016], \n    y = laliga['xpts_diff'][laliga['year'] == 2016],\n    name='2016',\n    mode = 'lines+markers'\n)\n\ntrace3 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2017], \n    y = laliga['xpts_diff'][laliga['year'] == 2017],\n    name='2017',\n    mode = 'lines+markers'\n)\n\ntrace4 = go.Scatter(\n    x = laliga['position'][laliga['year'] == 2018], \n    y = laliga['xpts_diff'][laliga['year'] == 2018],\n    name='2018',\n    mode = 'lines+markers'\n)\n\ndata = [trace0, trace1, trace2, trace3, trace4]\n\nlayout = go.Layout(\n    title=\"Comparing xPTS gap between positions\",\n    xaxis={'title': 'Position'},\n    yaxis={'title': \"xPTS difference\",\n    }\n)\n\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig)<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"450\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_700\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/xpts_gap.png\" alt=\"\" class=\"wp-image-942\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/xpts_gap.png 700w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/xpts_gap-300x193.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p>\u0417 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0445 \u0432\u0438\u0449\u0435 \u0434\u0456\u0430\u0433\u0440\u0430\u043c \u0432\u0438\u0434\u043d\u043e, \u0449\u043e \u043d\u0430\u0439\u043a\u0440\u0430\u0449\u0456 \u043a\u043e\u043c\u0430\u043d\u0434\u0438 \u0437\u0430\u0431\u0438\u0432\u0430\u044e\u0442\u044c \u0431\u0456\u043b\u044c\u0448\u0435, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u044c \u043c\u0435\u043d\u0448\u0435 \u0442\u0430 \u043e\u0442\u0440\u0438\u043c\u0443\u044e\u0442\u044c \u0431\u0456\u043b\u044c\u0448\u0435 \u043e\u0447\u043e\u043a, \u043d\u0456\u0436 \u043e\u0447\u0456\u043a\u0443\u0432\u0430\u043b\u043e\u0441\u044f. \u0422\u043e\u043c\u0443 \u0446\u0456 \u043a\u043e\u043c\u0430\u043d\u0434\u0438 - \u0442\u043e\u043f-\u043a\u043e\u043c\u0430\u043d\u0434\u0438. \u0406 \u0437\u043e\u0432\u0441\u0456\u043c \u043f\u0440\u043e\u0442\u0438\u043b\u0435\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u044f \u0437 \u0430\u0443\u0442\u0441\u0430\u0439\u0434\u0435\u0440\u0430\u043c\u0438. \u041a\u043e\u043c\u0430\u043d\u0434\u0438 \u0441\u0435\u0440\u0435\u0434\u043d\u044c\u043e\u0433\u043e \u0440\u0456\u0432\u043d\u044f \u0441\u0435\u0440\u0435\u0434\u043d\u0456. \u0426\u0456\u043b\u043a\u043e\u043c \u043b\u043e\u0433\u0456\u0447\u043d\u043e, \u0442\u0443\u0442 \u043d\u0435\u043c\u0430\u0454 \u043d\u0435\u0439\u043c\u043e\u0432\u0456\u0440\u043d\u0438\u0445 \u0437\u043d\u0430\u0445\u0456\u0434\u043e\u043a.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Check mean differences<\/em>\ndef get_diff_means(df):  \n  dm = df.groupby('year')[['xG_diff', 'xGA_diff', 'xpts_diff']].mean()\n  \n  return dm\n\nmeans = get_diff_means(laliga)\nmeans<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"236\" height=\"173\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/mean_diffs.jpg\" alt=\"\" class=\"wp-image-943\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Check median differences<\/em>\ndef get_diff_medians(df):  \n  dm = df.groupby('year')[['xG_diff', 'xGA_diff', 'xpts_diff']].median()\n  \n  return dm\n\nmedians = get_diff_medians(laliga)\nmedians<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"235\" height=\"172\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/median_diffs.jpg\" alt=\"\" class=\"wp-image-944\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Outliers-Detection\">\u0412\u0438\u044f\u0432\u043b\u0435\u043d\u043d\u044f \u0432\u0438\u043d\u044f\u0442\u043a\u0456\u0432<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Z-Score<\/h3>\n\n\n\n<p>Z-Score - \u043a\u0456\u043b\u044c\u043a\u0456\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0445 \u0432\u0456\u0434\u0445\u0438\u043b\u0435\u043d\u044c \u0432\u0456\u0434 \u0441\u0435\u0440\u0435\u0434\u043d\u044c\u043e\u0457 \u0442\u043e\u0447\u043a\u0438 \u0434\u0430\u043d\u0438\u0445. \u041c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 \u0439\u043e\u0433\u043e \u0434\u043b\u044f \u043f\u043e\u0448\u0443\u043a\u0443 \u0456\u043d\u0448\u0438\u0445 \u0432\u0438\u043d\u044f\u0442\u043a\u0456\u0432 \u0443 \u043d\u0430\u0448\u043e\u043c\u0443 \u043d\u0430\u0431\u043e\u0440\u0456 \u0434\u0430\u043d\u0438\u0445, \u0432\u0432\u0430\u0436\u0430\u044e\u0447\u0438, \u0449\u043e | z-\u043e\u0446\u0456\u043d\u043a\u0430 | > 3 - \u0432\u0438\u043d\u044f\u0442\u043e\u043a.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Getting outliers for xG using zscore<\/em>\nfrom scipy.stats import zscore\n<em># laliga[(np.abs(zscore(laliga[['xG_diff']])) > 2.0).all(axis=1)]<\/em>\ndf_xg[(np.abs(zscore(df_xg[['xG_diff']])) > 3.0).all(axis=1)]<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"197\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_764\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/z_score_1.jpg\" alt=\"\" class=\"wp-image-945\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_1.jpg 764w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_1-300x77.jpg 300w\" sizes=\"(max-width: 764px) 100vw, 764px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># outliers for xGA<\/em>\n<em># laliga[(np.abs(zscore(laliga[['xGA_diff']])) > 2.0).all(axis=1)]<\/em>\ndf_xg[(np.abs(zscore(df_xg[['xGA_diff']])) > 3.0).all(axis=1)]<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"745\" height=\"64\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_745\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/z_score_2.jpg\" alt=\"\" class=\"wp-image-946\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_2.jpg 745w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_2-300x26.jpg 300w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Outliers for xPTS<\/em>\n<em># laliga[(np.abs(zscore(laliga[['xpts_diff']])) > 2.0).all(axis=1)]<\/em>\ndf_xg[(np.abs(zscore(df_xg[['xpts_diff']])) > 3.0).all(axis=1)]<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"788\" height=\"130\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_788\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/z_score_3.jpg\" alt=\"\" class=\"wp-image-947\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_3.jpg 788w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_3-300x49.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/z_score_3-768x127.jpg 768w\" sizes=\"(max-width: 788px) 100vw, 788px\" \/><\/figure>\n\n\n\n<p>\u0412\u0441\u044c\u043e\u0433\u043e \u0432\u0438\u044f\u0432\u043b\u0435\u043d\u043e 12 \u0432\u0438\u043d\u044f\u0442\u043a\u0456\u0432. \u0411\u0456\u0434\u043d\u0430 \u041e\u0441\u0430\u0441\u0443\u043d\u0430 \u0432 2016 \u0440\u043e\u0446\u0456 - \u043c\u0430\u0439\u0436\u0435 30 \u043d\u0435\u0437\u0430\u0441\u043b\u0443\u0436\u0435\u043d\u0438\u0445 \u0433\u043e\u043b\u0456\u0432.<\/p>\n\n\n\n<p>\u042f\u043a \u043c\u0438 \u0431\u0430\u0447\u0438\u043c\u043e \u0437 \u0446\u0438\u0445 \u0434\u0430\u043d\u0438\u0445, \u043f\u0435\u0440\u0435\u0431\u0443\u0432\u0430\u043d\u043d\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0456 \u0432\u0438\u043d\u044f\u0442\u043a\u0456\u0432, \u0449\u0435 \u043d\u0435 \u0440\u043e\u0431\u0438\u0442\u044c \u0432\u0430\u0441 \u043f\u0435\u0440\u0435\u043c\u043e\u0436\u0446\u0435\u043c \u0441\u0435\u0437\u043e\u043d\u0443. \u0410\u043b\u0435 \u044f\u043a\u0449\u043e \u0432\u0438 \u0432\u0442\u0440\u0430\u0447\u0430\u0454\u0442\u0435 \u0441\u0432\u043e\u0457 \u043c\u043e\u0436\u043b\u0438\u0432\u043e\u0441\u0442\u0456 \u0430\u0431\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0454\u0442\u0435 \u0433\u043e\u043b\u0438 \u0442\u0430\u043c, \u0434\u0435 \u043d\u0435 \u0441\u043b\u0456\u0434, \u0456 \u0440\u043e\u0431\u0438\u0442\u0435 \u0446\u0435 \u0437\u0430\u043d\u0430\u0434\u0442\u043e \u0447\u0430\u0441\u0442\u043e - \u0432\u0438 \u0437\u0430\u0441\u043b\u0443\u0433\u043e\u0432\u0443\u0454\u0442\u0435 \u043d\u0430 \u0432\u0438\u043b\u0456\u0442. \u041f\u0440\u043e\u0433\u0440\u0430\u0432\u0430\u0442\u0438 \u0456 \u0431\u0443\u0442\u0438 \u0441\u0435\u0440\u0435\u0434\u043d\u0456\u043c \u043d\u0430\u0431\u0430\u0433\u0430\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0456\u0448\u0435, \u043d\u0456\u0436 \u0432\u0438\u0433\u0440\u0430\u0432\u0430\u0442\u0438.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u041c\u0456\u0436\u043a\u0432\u0430\u0440\u0442\u0438\u043b\u044c\u043d\u0438\u0439 \u0434\u0456\u0430\u043f\u0430\u0437\u043e\u043d (IQR)<\/h3>\n\n\n\n<p>IQR - \u0440\u0456\u0437\u043d\u0438\u0446\u044f \u043c\u0456\u0436 \u043f\u0435\u0440\u0448\u0438\u043c \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u043e\u043c \u0456 \u0442\u0440\u0435\u0442\u0456\u043c \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0443 \u0434\u0430\u043d\u0438\u0445. \u0426\u0435 \u043e\u0434\u0438\u043d \u0456\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u0456\u0432 \u043e\u043f\u0438\u0441\u0430\u0442\u0438 \u043f\u043e\u0448\u0438\u0440\u0435\u043d\u043d\u044f \u043d\u0430\u0431\u043e\u0440\u0443 \u0434\u0430\u043d\u0438\u0445.<\/p>\n\n\n\n<p>\u0417\u0430\u0433\u0430\u043b\u044c\u043d\u043e\u0432\u0436\u0438\u0432\u0430\u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c, \u0449\u043e \u0442\u043e\u0447\u043a\u0430 \u0434\u0430\u043d\u0438\u0445 \u0454 \u0432\u0438\u043d\u044f\u0442\u043a\u043e\u043c, \u044f\u043a\u0449\u043e \u0432\u043e\u043d\u0430 \u0431\u0456\u043b\u044c\u0448\u0435 1,5 \u22c5 IQR \u0442\u0440\u0435\u0442\u044c\u043e\u0433\u043e \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0443 \u0430\u0431\u043e \u043d\u0430 \u0441\u0442\u0456\u043b\u044c\u043a\u0438 \u0436 \u043d\u0438\u0436\u0447\u0435 \u043f\u0435\u0440\u0448\u043e\u0433\u043e \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0443. \u0406\u043d\u0448\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043d\u0438\u0437\u044c\u043a\u0456 \u0432\u0438\u043d\u044f\u0442\u043a\u0438 \u0454 \u043d\u0438\u0436\u0447\u0438\u043c\u0438 \u0437\u0430 Q1 - 1,5 \u22c5 IQR, \u0430 \u0432\u0438\u0441\u043e\u043a\u0456 - \u043f\u043e\u043d\u0430\u0434 Q3 + 1,5 \u22c5 IQR.<\/p>\n\n\n\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u0438\u043c\u043e \u0446\u0435.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Trying different method of outliers detection<\/em>\ndf_xg.describe()<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"222\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_693\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/describe_2.jpg\" alt=\"\" class=\"wp-image-948\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/describe_2.jpg 693w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/describe_2-300x96.jpg 300w\" sizes=\"(max-width: 693px) 100vw, 693px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># using Interquartile Range Method to identify outliers<\/em>\n<em># xG_diff<\/em>\niqr_xG = (df_xg.describe().loc['75%','xG_diff'] - df_xg.describe().loc['25%','xG_diff']) * 1.5\nupper_xG = df_xg.describe().loc['75%','xG_diff'] + iqr_xG\nlower_xG = df_xg.describe().loc['25%','xG_diff'] - iqr_xG\n\nprint('IQR for xG_diff: <strong>{:.2f}<\/strong>'.format(iqr_xG))\nprint('Upper border for xG_diff: <strong>{:.2f}<\/strong>'.format(upper_xG))\nprint('Lower border for xG_diff: <strong>{:.2f}<\/strong>'.format(lower_xG))\n\noutliers_xG = df_xg[(df_xg['xG_diff'] > upper_xG) | (df_xg['xG_diff'] < lower_xG)]\nprint('='*50)\n\n<em># xGA_diff<\/em>\niqr_xGA = (df_xg.describe().loc['75%','xGA_diff'] - df_xg.describe().loc['25%','xGA_diff']) * 1.5\nupper_xGA = df_xg.describe().loc['75%','xGA_diff'] + iqr_xGA\nlower_xGA = df_xg.describe().loc['25%','xGA_diff'] - iqr_xGA\n\nprint('IQR for xGA_diff: <strong>{:.2f}<\/strong>'.format(iqr_xGA))\nprint('Upper border for xGA_diff: <strong>{:.2f}<\/strong>'.format(upper_xGA))\nprint('Lower border for xGA_diff: <strong>{:.2f}<\/strong>'.format(lower_xGA))\n\noutliers_xGA = df_xg[(df_xg['xGA_diff'] > upper_xGA) | (df_xg['xGA_diff'] < lower_xGA)]\nprint('='*50)\n\n<em># xpts_diff<\/em>\niqr_xpts = (df_xg.describe().loc['75%','xpts_diff'] - df_xg.describe().loc['25%','xpts_diff']) * 1.5\nupper_xpts = df_xg.describe().loc['75%','xpts_diff'] + iqr_xpts\nlower_xpts = df_xg.describe().loc['25%','xpts_diff'] - iqr_xpts\n\nprint('IQR for xPTS_diff: <strong>{:.2f}<\/strong>'.format(iqr_xpts))\nprint('Upper border for xPTS_diff: <strong>{:.2f}<\/strong>'.format(upper_xpts))\nprint('Lower border for xPTS_diff: <strong>{:.2f}<\/strong>'.format(lower_xpts))\n\noutliers_xpts = df_xg[(df_xg['xpts_diff'] > upper_xpts) | (df_xg['xpts_diff'] < lower_xpts)]\nprint('='*50)\n\noutliers_full = pd.concat([outliers_xG, outliers_xGA, outliers_xpts])\noutliers_full = outliers_full.drop_duplicates()\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">IQR \u0434\u043b\u044f xG_diff: 13.16\n\u0412\u0435\u0440\u0445\u043d\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044f \u0434\u043b\u044f xG_diff: 16.65\n\u041d\u0438\u0436\u043d\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044f \u0434\u043b\u044f  xG_diff: -18.43\n==================================================\nIQR \u0434\u043b\u044f xGA_diff: 13.95\n\u0412\u0435\u0440\u0445\u043d\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044f \u0434\u043b\u044f  xGA_diff: 17.15\n\u041d\u0438\u0436\u043d\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044f \u0434\u043b\u044f  xGA_diff: -20.05\n==================================================\nIQR \u0434\u043b\u044f xPTS_diff: 13.93\n\u0412\u0435\u0440\u0445\u043d\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044f \u0434\u043b\u044f  xPTS_diff: 18.73\n\u041d\u0438\u0436\u043d\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u044f \u0434\u043b\u044f  xPTS_diff: -18.41\n==================================================<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Adding ratings bottom to up to find looser in each league (different amount of teams in every league so I can't do just n-20)<\/em>\nmax_position = df_xg.groupby('league')['position'].max()\ndf_xg['position_reverse'] = np.nan\noutliers_full['position_reverse'] = np.nan\n\nfor i, row <strong>in<\/strong> df_xg.iterrows():\n  df_xg.at[i, 'position_reverse'] = np.abs(row['position'] - max_position[row['league']])+1\n  \nfor i, row <strong>in<\/strong> outliers_full.iterrows():\n  outliers_full.at[i, 'position_reverse'] = np.abs(row['position'] - max_position[row['league']])+1<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">total_count = df_xg[(df_xg['position'] <= 4) | (df_xg['position_reverse'] <= 3)].count()[0]\noutlier_count = outliers_full[(outliers_full['position'] <= 4) | (outliers_full['position_reverse'] <= 3)].count()[0]\noutlier_prob = outlier_count \/ total_count\nprint('Probability of outlier in top or bottom of the final table: <strong>{:.2%}<\/strong>'.format(outlier_prob))<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\u0419\u043c\u043e\u0432\u0456\u0440\u043d\u0456\u0441\u0442\u044c \u0432\u0438\u043d\u044f\u0442\u043a\u0443 \u0432 \u0432\u0435\u0440\u0445\u043d\u0456\u0439 \u0447\u0438 \u043d\u0438\u0436\u043d\u0456\u0439 \u0447\u0430\u0441\u0442\u0438\u043d\u0456 \u0444\u0456\u043d\u0430\u043b\u044c\u043d\u043e\u0457 \u0442\u0430\u0431\u043b\u0438\u0446\u0456: 8.10%<\/pre>\n\n\n\n<p>\u0422\u043e\u0436 \u043c\u043e\u0436\u043d\u0430 \u0441\u043a\u0430\u0437\u0430\u0442\u0438, \u0449\u043e \u0434\u0443\u0436\u0435 \u0439\u043c\u043e\u0432\u0456\u0440\u043d\u043e, \u0449\u043e \u0449\u043e\u0440\u043e\u043a\u0443 \u0432 \u043e\u0434\u043d\u0456\u0439 \u0456\u0437 6 \u043b\u0456\u0433 \u0431\u0443\u0434\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u044f\u043a\u0430 \u043e\u0442\u0440\u0438\u043c\u0443\u0454 \u043f\u0443\u0442\u0456\u0432\u043a\u0443 \u0434\u043e \u041b\u0456\u0433\u0438 \u0447\u0435\u043c\u043f\u0456\u043e\u043d\u0456\u0432 \u0447\u0438 \u041b\u0456\u0433\u0438 \u0404\u0432\u0440\u043e\u043f\u0438 \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u0443\u0434\u0430\u0447\u0456, \u043e\u043a\u0440\u0456\u043c \u0441\u0432\u043e\u0457\u0445 \u0447\u0443\u0434\u043e\u0432\u0438\u0445 \u043d\u0430\u0432\u0438\u0447\u043e\u043a, \u0430\u0431\u043e \u0454 \u043d\u0435\u0432\u0434\u0430\u0445\u0430, \u044f\u043a\u0430 \u043f\u0430\u0434\u0430\u0454 \u0434\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0434\u0438\u0432\u0456\u0437\u0456\u043e\u043d\u0443, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0432\u043e\u043d\u0438 \u043d\u0435 \u043c\u043e\u0436\u0443\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0443\u0432\u0430\u0442\u0438 \u0441\u0432\u043e\u0457 \u043c\u043e\u043c\u0435\u043d\u0442\u0438.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># 1-3 outliers among all leagues in a year<\/em>\ndata = pd.DataFrame(outliers_full.groupby('league')['year'].count()).reset_index()\ndata = data.rename(index=int, columns={'year': 'outliers'})\nsns.barplot(x='league', y='outliers', data=data)\n<em># no outliers in Bundesliga<\/em><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"274\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_398\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/outliers.jpg\" alt=\"\" class=\"wp-image-949\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/outliers.jpg 398w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/outliers-300x207.jpg 300w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/figure>\n\n\n\n<p>\u041d\u0430\u0448\u0456 \u043f\u0435\u0440\u0435\u043c\u043e\u0436\u0446\u0456 \u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u043e\u0436\u0435\u043d\u0456 \u0437 \u0431\u043b\u0438\u0441\u043a\u0443\u0447\u0438\u043c\u0438 \u0434\u0430\u043d\u0438\u043c\u0438 \u0442\u0430 \u043d\u0435 \u0434\u0443\u0436\u0435.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">top_bottom = outliers_full[(outliers_full['position'] <= 4) | (outliers_full['position_reverse'] <= 3)].sort_values(by='league')\ntop_bottom<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"819\" height=\"499\" src=\"https:\/\/cdn.shortpixel.ai\/client\/q_glossy,ret_img,w_819\/http:\/\/35.180.88.53\/wp-content\/uploads\/2019\/09\/top_bottom.jpg\" alt=\"\" class=\"wp-image-950\" srcset=\"https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/top_bottom.jpg 819w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/top_bottom-300x183.jpg 300w, https:\/\/www.sergilehkyi.com\/wp-content\/uploads\/2019\/09\/top_bottom-768x468.jpg 768w\" sizes=\"(max-width: 819px) 100vw, 819px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted\"><em># Let's get back to our list of teams that suddenly got into top. Was that because of unbeliavable mix of luck and skill?<\/em>\not = [x for x  <strong>in<\/strong> outlier_teams if x <strong>in<\/strong> top_bottom['team'].drop_duplicates().tolist()]\not\n<em># The answer is absolutely no. They just played well during 1 season. Sometimes that happen.<\/em><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">[]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u0412\u0438\u0441\u043d\u043e\u0432\u043a\u0438<\/h2>\n\n\n\n<p>\u0424\u0443\u0442\u0431\u043e\u043b - \u0446\u0435 \u0433\u0440\u0430 \u0437 \u043d\u0438\u0437\u044c\u043a\u0438\u043c \u0440\u0456\u0432\u043d\u0435\u043c \u0431\u0430\u043b\u0456\u0432, \u0456 \u043e\u0434\u0438\u043d \u0433\u043e\u043b \u043c\u043e\u0436\u0435 \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0432\u0441\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0433\u0440\u0438 \u0456 \u043d\u0430\u0432\u0456\u0442\u044c \u043a\u0456\u043d\u0446\u0435\u0432\u0456 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438. \u041e\u0441\u044c \u0447\u043e\u043c\u0443 \u0434\u043e\u0432\u0433\u043e\u0441\u0442\u0440\u043e\u043a\u043e\u0432\u0438\u0439 \u0430\u043d\u0430\u043b\u0456\u0437 \u0434\u0430\u0454 \u043d\u0430\u043c \u043a\u0440\u0430\u0449\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0456\u0457.<\/p>\n\n\n\n<p>\u0417 \u0432\u043f\u0440\u043e\u0432\u0430\u0434\u0436\u0435\u043d\u043d\u044f\u043c \u043c\u0435\u0442\u0440\u0438\u043a\u0438 xG (\u0442\u0430 \u0456\u043d\u0448\u0438\u0445, \u0449\u043e \u0432\u0438\u043f\u043b\u0438\u0432\u0430\u044e\u0442\u044c \u0437 \u043d\u044c\u043e\u0433\u043e) \u0442\u0435\u043f\u0435\u0440 \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0446\u0456\u043d\u0438\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438 \u0440\u043e\u0431\u043e\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0438 \u0432 \u0434\u043e\u0432\u0433\u043e\u0441\u0442\u0440\u043e\u043a\u043e\u0432\u0456\u0439 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0456 \u0456 \u0437\u0440\u043e\u0437\u0443\u043c\u0456\u0442\u0438 \u0440\u0456\u0437\u043d\u0438\u0446\u044e \u043c\u0456\u0436 \u0442\u043e\u043f-\u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438, \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c\u0438 \u0441\u0435\u0440\u0435\u0434\u043d\u044c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0443 \u0442\u0430 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0438\u043c\u0438 \u0430\u0443\u0442\u0441\u0430\u0439\u0434\u0435\u0440\u0430\u043c\u0438.<\/p>\n\n\n\n<p>xG \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u043e\u0432\u0456 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0438 \u0432 \u0434\u0438\u0441\u043a\u0443\u0441\u0456\u0457 \u043d\u0430\u0432\u043a\u043e\u043b\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u0443, \u0449\u043e \u0440\u043e\u0431\u0438\u0442\u044c \u0439\u043e\u0433\u043e \u0449\u0435 \u0446\u0456\u043a\u0430\u0432\u0456\u0448\u0438\u043c. \u0406 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0447\u0430\u0441 \u0433\u0440\u0430 \u043d\u0435 \u0432\u0442\u0440\u0430\u0447\u0430\u0454 \u0446\u0435\u0439 \u0444\u0430\u043a\u0442\u043e\u0440 \u043d\u0435\u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u043e\u0441\u0442\u0456 \u0442\u0430 \u043c\u043e\u0436\u043b\u0438\u0432\u043e\u0441\u0442\u0456 \u0431\u043e\u0436\u0435\u0432\u0456\u043b\u044c\u043d\u0438\u0445 \u0440\u0435\u0447\u0435\u0439. \u041d\u0430\u0441\u043f\u0440\u0430\u0432\u0434\u0456 \u0437\u0430\u0440\u0430\u0437 \u0446\u0456 \u0448\u0430\u043b\u0435\u043d\u0456 \u0440\u0435\u0447\u0456 \u043c\u0430\u044e\u0442\u044c \u0448\u0430\u043d\u0441 \u0431\u0443\u0442\u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u043c\u0438.<\/p>\n\n\n\n<p>\u0412\u0440\u0435\u0448\u0442\u0456-\u0440\u0435\u0448\u0442 \u043c\u0438 \u0432\u0438\u044f\u0432\u0438\u043b\u0438, \u0449\u043e \u043c\u0430\u0439\u0436\u0435 \u0432 100% \u0448\u0430\u043d\u0441\u0438 \u0432 \u043e\u0434\u043d\u0456\u0439 \u0437 \u043b\u0456\u0433 \u0442\u0440\u0430\u043f\u0438\u0442\u044c\u0441\u044f \u0449\u043e\u0441\u044c \u0434\u0438\u0432\u043d\u0435. \u0426\u0435 \u043b\u0438\u0448\u0435 \u043f\u0438\u0442\u0430\u043d\u043d\u044f \u0447\u0430\u0441\u0443, \u043d\u0430\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0435\u043f\u0456\u0447\u043d\u0438\u043c \u0446\u0435 \u0431\u0443\u0434\u0435.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p style=\"text-align:center\">\u041e\u0440\u0438\u0433\u0456\u043d\u0430\u043b\u044c\u043d\u0430 \u0440\u043e\u0431\u043e\u0442\u0430 \u0437 \u0456\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u0438\u043c\u0438 \u0433\u0440\u0430\u0444\u0456\u043a\u0430\u043c\u0438 \u043c\u043e\u0436\u0435 \u0431\u0443\u0442\u0438 \u0437\u043d\u0430\u0439\u0434\u0435\u043d\u0430\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.kaggle.com\/slehkyi\/football-why-winners-win-and-losers-loose\" target=\"_blank\">\u0442\u0443\u0442.<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p style=\"text-align:center\">\u0424\u043e\u0442\u043e\u00a0<a href=\"https:\/\/unsplash.com\/@viennachanges?utm_source=unsplash&#038;utm_medium=referral&#038;utm_content=creditCopyText\">Vienna Reyes<\/a>\u00a0\u043d\u0430\u00a0<a href=\"https:\/\/unsplash.com\/search\/photos\/soccer?utm_source=unsplash&#038;utm_medium=referral&#038;utm_content=creditCopyText\">Unsplash<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0414\u0438\u0432\u0438\u043c\u043e\u0441\u044c 5 \u0440\u043e\u043a\u0456\u0432 \u0454\u0432\u0440\u043e\u043f\u0435\u0439\u0441\u044c\u043a\u043e\u0433\u043e \u0444\u0443\u0442\u0431\u043e\u043b\u0443 \u0406\u043d\u0442\u0440\u043e \u0423 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456 \u043c\u0438 \u0432\u0438\u0432\u0447\u0438\u043c\u043e \u0441\u0443\u0447\u0430\u0441\u043d\u0456 \u043f\u043e\u043a\u0430\u0437\u043d\u0438\u043a\u0438 \u0443 \u0444\u0443\u0442\u0431\u043e\u043b\u0456 (xG, xGA \u0442\u0430 xPTS) \u0442\u0430&hellip;<\/p>\n","protected":false},"author":1,"featured_media":952,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"translation":{"provider":"WPGlobus","version":"3.0.0","language":"uk","enabled_languages":["gb","es","uk"],"languages":{"gb":{"title":true,"content":true,"excerpt":false},"es":{"title":true,"content":true,"excerpt":false},"uk":{"title":true,"content":true,"excerpt":false}}},"_links":{"self":[{"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/posts\/917"}],"collection":[{"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/comments?post=917"}],"version-history":[{"count":26,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/posts\/917\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/posts\/917\/revisions\/998"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/media\/952"}],"wp:attachment":[{"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/media?parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/categories?post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sergilehkyi.com\/uk\/wp-json\/wp\/v2\/tags?post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}