{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"regular_detail = pd.read_csv('../input/march-madness-analytics-2020/MDataFiles_Stage2/MRegularSeasonDetailedResults.csv')\ntour_detail = pd.read_csv('../input/march-madness-analytics-2020/MDataFiles_Stage2/MNCAATourneyDetailedResults.csv')\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# create new columns for 2 points shot\nregular_detail['WFGM2'] = regular_detail['WFGM'] - regular_detail['WFGM3']\nregular_detail['WFGA2'] = regular_detail['WFGA'] - regular_detail['WFGA3']\nregular_detail['LFGM2'] = regular_detail['LFGM'] - regular_detail['LFGM3']\nregular_detail['LFGA2'] = regular_detail['LFGA'] - regular_detail['LFGA3']\n\nw_detail = regular_detail[['Season', 'WScore', 'WFGM', 'WFGA', 'WFGM2', 'WFGA2', 'WFGM3', 'WFGA3', 'WFTM', 'WFTA',\n                                'WOR', 'WDR', 'WAst','WTO', 'WStl', 'WBlk', 'WPF']]\nl_detail = regular_detail[['Season', 'LScore', 'LFGM', 'LFGA', 'LFGM2', 'LFGA2', 'LFGM3', 'LFGA3', 'LFTM', 'LFTA',\n                                'LOR', 'LDR', 'LAst','LTO', 'LStl', 'LBlk', 'LPF']]\n\nnew_columns = ['Season', 'Score', 'FGM', 'FGA', 'FGM2', 'FGA2', 'FGM3', 'FGA3', 'FTM', \n               'FTA', 'OR', 'DR', 'Ast','TO', 'Stl', 'Blk', 'PF']\n\n\nw_detail.columns = new_columns\nl_detail.columns = new_columns\n\nall_detail = pd.concat([w_detail, l_detail])\n\nw_detail = w_detail.groupby('Season').mean().round(2)\nl_detail = l_detail.groupby('Season').mean().round(2)\nall_detail = all_detail.groupby('Season').mean().round(2)\nall_detail","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# **Stats of Winning Teams**"},{"metadata":{"trusted":true},"cell_type":"code","source":"w_detail","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Stats of Losing Teams"},{"metadata":{"trusted":true},"cell_type":"code","source":"l_detail","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns\nsns.set();\n%matplotlib inline\nplt.rcParams[\"figure.figsize\"] = (10,5)\n\nyear = [i for i in range(2003, 2021)]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Score Difference"},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.plot(year, w_detail.Score, marker='o')\nplt.plot(year, l_detail.Score, marker='o')\nplt.xticks(year);\n\nplt.title('Average Score of Winning and Losing Teams Over Time');\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Evolution of 3-Point"},{"metadata":{"trusted":true},"cell_type":"code","source":"fig, (ax, ax2) = plt.subplots(2, 1)\n\nfig.suptitle('3-Point Attempt VS 2-Point Attempt');\nax.plot(year, all_detail.FGA2, marker='o', label='2-Point', c='r')\nax.set_yticks([i for i in range(35, 40)])\nax.set_xticks(year);\n\nax2.plot(year, all_detail.FGA3, marker='o', label='3-Point')\nax2.set_xticks(year);\n\nfor ax in fig.get_axes():\n    ax.label_outer()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"We can see that although 2 point shot is still the major weapon on offence, teams have increased their 3-point attempts throughout the years."},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.plot(year, all_detail.FGM3/all_detail.FGA3, marker='o')\nplt.xticks(year);\nplt.title('3-Point Percentage Change');","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"However, the efficiency of 3-pointer does not seem to increase"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}