{"cells":[{"metadata":{"_uuid":"2fd2819e-1be6-48be-9e79-c74dc6462d1a","_cell_guid":"b862e4aa-c76f-43d9-b682-f6a13beb8f59","trusted":true,"collapsed":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.\n\nfrom IPython.core.interactiveshell import InteractiveShell\nInteractiveShell.ast_node_interactivity = \"all\"\n#print multiple outputs","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9a54d62e-eaa9-4f26-aec6-8e60f0e85d47","_cell_guid":"8854a957-d90a-437d-aeaa-7667bc53741a","trusted":true},"cell_type":"code","source":"\nMEvents2015 = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MEvents2015.csv\")\nMEvents2016 = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MEvents2016.csv\")\nMEvents2017 = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MEvents2017.csv\")\nMEvents2018 = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MEvents2018.csv\")\nMEvents2019 = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MEvents2019.csv\")\nMPlayers = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MPlayers.csv\")\nMSampleSubmissionStage1_2020 = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MSampleSubmissionStage1_2020.csv\")\n\nSeasons = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MSeasons.csv\")\nConferences = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/Conferences.csv\")\nTeamConferences = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MTeamConferences.csv\")\nCoaches = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MTeamCoaches.csv\")\nTeams = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MTeams.csv\")\nCities = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/Cities.csv\")\nMassey = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MMasseyOrdinals.csv\")\nTeamSpellings = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MTeamSpellings.csv\", encoding = \"ISO-8859-1\")\nGameCities = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MGameCities.csv\")\nSeeds = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneySeeds.csv\")\nSlots = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneySlots.csv\")\nRound_Slots = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneySeedRoundSlots.csv\")\n\nNCAACompact = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneyCompactResults.csv\")\nNCAADetailed = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MNCAATourneyDetailedResults.csv\")\nSeasonCompact = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MRegularSeasonCompactResults.csv\")\nSeasonDetailed = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MRegularSeasonDetailedResults.csv\")\nNITTeams = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MSecondaryTourneyTeams.csv\")\nNITCompact = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MSecondaryTourneyCompactResults.csv\")\nConfTourneyGames = pd.read_csv(\"../input/google-cloud-ncaa-march-madness-2020-division-1-mens-tournament/MDataFiles_Stage1/MConferenceTourneyGames.csv\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6968e0b9-cf52-4250-be03-2e06b0c1574d","_cell_guid":"8d95d596-101e-4f03-b8c6-fb014744cc63","trusted":true},"cell_type":"code","source":"#process data\n#Add Full Name to Conferences. \n#Create seednum column \n#Combine regular season + tourney detailed data after adding tourney (T/F) column to both frames\nTeamConferences = (pd.merge(TeamConferences, Conferences, on='ConfAbbrev')\n                  .rename({'Description': 'conf_descr'}, axis=1))\nSeeds['seednum'] = Seeds ['Seed'].str.slice(1,3).astype(int)\nSeasonDetailed['tourney'] = 0\nNCAADetailed['tourney'] = 1\ngamedata = pd.concat([SeasonDetailed, NCAADetailed])\ngamedata","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d37c975d-f732-4f8a-a7e0-abf33d6b6635","_cell_guid":"dbe37db1-f938-4fc6-8506-5e9c31066592","trusted":true},"cell_type":"code","source":"    # team1: team with lower id\ngamedata['team1'] = (gamedata['WTeamID'].where(gamedata['WTeamID'] < gamedata['LTeamID'],\n                                           gamedata['LTeamID']))\n    # team2: team with higher id\ngamedata['team2'] = (gamedata['WTeamID'].where(gamedata['WTeamID'] > gamedata['LTeamID'],\n                                           gamedata['LTeamID']))\ngamedata['score1'] = gamedata['WScore'].where(gamedata['WTeamID'] < gamedata['LTeamID'], gamedata['LScore'])\ngamedata['score2'] = gamedata['WScore'].where(gamedata['WTeamID'] > gamedata['LTeamID'], gamedata['LScore'])\n\nboxscore_stats = ['FGM', 'FGA', 'FGM3', 'FGA3', 'FTM', 'FTA',\n                      'OR', 'DR', 'Ast', 'TO', 'Stl', 'Blk', 'PF',]","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9853b6b3-17fe-4966-9616-2958429537c3","_cell_guid":"c4c14e76-4ab8-4fd3-8558-03853bf17b20","trusted":true},"cell_type":"code","source":"gamedata","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"767ecf95-418e-4a14-9bbf-5c0bc2d216c2","_cell_guid":"cbaf6b68-49bf-40e9-8209-0190d92de3ba","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}