{"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_minor":4,"nbformat":4,"cells":[{"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\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 read-only \"../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# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-10-22T07:37:48.730404Z","iopub.execute_input":"2021-10-22T07:37:48.730666Z","iopub.status.idle":"2021-10-22T07:37:48.737407Z","shell.execute_reply.started":"2021-10-22T07:37:48.730638Z","shell.execute_reply":"2021-10-22T07:37:48.736313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd \nimport numpy as np \nimport matplotlib.pyplot as plt \nimport seaborn as sns \nimport warnings \nimport plotly.express as px\nwarnings.filterwarnings('ignore')","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:37:48.738968Z","iopub.execute_input":"2021-10-22T07:37:48.739433Z","iopub.status.idle":"2021-10-22T07:37:48.760740Z","shell.execute_reply.started":"2021-10-22T07:37:48.739388Z","shell.execute_reply":"2021-10-22T07:37:48.759534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### File descriptions\nGame data: The games.csv contains the teams playing in each game. The key variable is gameId.\n\nPlay data: The plays.csv file contains play-level information from each game. The key variables are gameId and playId.\n\nPlayer data: The players.csv file contains player-level information from players that participated in any of the tracking data files. The key variable is nflId.\n\nTracking data: Files tracking[season].csv contain player tracking data from season [season]. The key variables are gameId, playId, and nflId.\n\nPFF Scouting data: The PFFScoutingData.csv file contains play-level scouting information for each game. The key variables are gameId and playId.","metadata":{}},{"cell_type":"code","source":"player = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/players.csv\")\nScouting = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/PFFScoutingData.csv\")\ngames = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/games.csv\")\nplays = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/plays.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:37:48.763508Z","iopub.execute_input":"2021-10-22T07:37:48.764015Z","iopub.status.idle":"2021-10-22T07:37:48.892681Z","shell.execute_reply.started":"2021-10-22T07:37:48.763968Z","shell.execute_reply":"2021-10-22T07:37:48.891825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking_2018 = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/tracking2018.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:37:48.894575Z","iopub.execute_input":"2021-10-22T07:37:48.894801Z","iopub.status.idle":"2021-10-22T07:38:12.573895Z","shell.execute_reply.started":"2021-10-22T07:37:48.894775Z","shell.execute_reply":"2021-10-22T07:38:12.573080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking_2019 = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/tracking2019.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:38:12.575334Z","iopub.execute_input":"2021-10-22T07:38:12.575982Z","iopub.status.idle":"2021-10-22T07:38:36.164643Z","shell.execute_reply.started":"2021-10-22T07:38:12.575935Z","shell.execute_reply":"2021-10-22T07:38:36.163699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking_2020 = pd.read_csv(\"/kaggle/input/nfl-big-data-bowl-2022/tracking2020.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:38:36.166193Z","iopub.execute_input":"2021-10-22T07:38:36.166451Z","iopub.status.idle":"2021-10-22T07:39:05.847456Z","shell.execute_reply.started":"2021-10-22T07:38:36.166419Z","shell.execute_reply":"2021-10-22T07:39:05.846796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"player.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:05.849033Z","iopub.execute_input":"2021-10-22T07:39:05.849372Z","iopub.status.idle":"2021-10-22T07:39:05.862758Z","shell.execute_reply.started":"2021-10-22T07:39:05.849330Z","shell.execute_reply":"2021-10-22T07:39:05.861803Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Player -- Table Analysis","metadata":{}},{"cell_type":"markdown","source":"Player file contain 2732 unique player record and nflId is the key variable here. We can use this id in leter analysis. ","metadata":{}},{"cell_type":"code","source":"player[\"nflId\"].nunique(), player.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:05.863979Z","iopub.execute_input":"2021-10-22T07:39:05.864438Z","iopub.status.idle":"2021-10-22T07:39:05.878365Z","shell.execute_reply.started":"2021-10-22T07:39:05.864398Z","shell.execute_reply":"2021-10-22T07:39:05.877719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"player.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:05.880670Z","iopub.execute_input":"2021-10-22T07:39:05.881091Z","iopub.status.idle":"2021-10-22T07:39:05.897350Z","shell.execute_reply.started":"2021-10-22T07:39:05.881053Z","shell.execute_reply":"2021-10-22T07:39:05.896547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"player[\"Position\"].value_counts().nlargest(5)","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:05.898859Z","iopub.execute_input":"2021-10-22T07:39:05.899362Z","iopub.status.idle":"2021-10-22T07:39:05.912442Z","shell.execute_reply.started":"2021-10-22T07:39:05.899330Z","shell.execute_reply":"2021-10-22T07:39:05.911494Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(style='darkgrid')\nax = sns.countplot(x = 'Position',\n              data = player,\n              order = player[\"Position\"].value_counts().index)\n\nax.set_xlabel(\" Player Position \")\nax.set_ylabel(\" Count of People pr position \")\nplt.xticks(rotation=70)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:05.914112Z","iopub.execute_input":"2021-10-22T07:39:05.914427Z","iopub.status.idle":"2021-10-22T07:39:06.292623Z","shell.execute_reply.started":"2021-10-22T07:39:05.914389Z","shell.execute_reply":"2021-10-22T07:39:06.291762Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.distplot(player[\"weight\"])","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.293693Z","iopub.execute_input":"2021-10-22T07:39:06.293922Z","iopub.status.idle":"2021-10-22T07:39:06.617954Z","shell.execute_reply.started":"2021-10-22T07:39:06.293894Z","shell.execute_reply":"2021-10-22T07:39:06.617135Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Scouting table Analysis ","metadata":{}},{"cell_type":"code","source":"Scouting.head(2)","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.618943Z","iopub.execute_input":"2021-10-22T07:39:06.619372Z","iopub.status.idle":"2021-10-22T07:39:06.639205Z","shell.execute_reply.started":"2021-10-22T07:39:06.619341Z","shell.execute_reply":"2021-10-22T07:39:06.638334Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Scouting.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.640290Z","iopub.execute_input":"2021-10-22T07:39:06.640500Z","iopub.status.idle":"2021-10-22T07:39:06.650855Z","shell.execute_reply.started":"2021-10-22T07:39:06.640476Z","shell.execute_reply":"2021-10-22T07:39:06.649873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Scouting.gameId.nunique()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.652208Z","iopub.execute_input":"2021-10-22T07:39:06.652526Z","iopub.status.idle":"2021-10-22T07:39:06.664377Z","shell.execute_reply.started":"2021-10-22T07:39:06.652483Z","shell.execute_reply":"2021-10-22T07:39:06.663431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Scouting.playId.nunique()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.665547Z","iopub.execute_input":"2021-10-22T07:39:06.665775Z","iopub.status.idle":"2021-10-22T07:39:06.674418Z","shell.execute_reply.started":"2021-10-22T07:39:06.665749Z","shell.execute_reply":"2021-10-22T07:39:06.673601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Scouting[\"snapDetail\"].value_counts()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.675747Z","iopub.execute_input":"2021-10-22T07:39:06.676438Z","iopub.status.idle":"2021-10-22T07:39:06.688082Z","shell.execute_reply.started":"2021-10-22T07:39:06.676390Z","shell.execute_reply":"2021-10-22T07:39:06.686963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(style='darkgrid')\nax = sns.countplot(x = 'snapDetail',\n              data = Scouting,\n              order = Scouting[\"snapDetail\"].value_counts().index)\n\nax.set_xlabel(\" Player snapDetails \")\nax.set_ylabel(\" Count \")\nplt.xticks(rotation=70)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.689470Z","iopub.execute_input":"2021-10-22T07:39:06.690098Z","iopub.status.idle":"2021-10-22T07:39:06.896524Z","shell.execute_reply.started":"2021-10-22T07:39:06.690047Z","shell.execute_reply":"2021-10-22T07:39:06.895478Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Scouting.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.898008Z","iopub.execute_input":"2021-10-22T07:39:06.898313Z","iopub.status.idle":"2021-10-22T07:39:06.921284Z","shell.execute_reply.started":"2021-10-22T07:39:06.898268Z","shell.execute_reply":"2021-10-22T07:39:06.920257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(Scouting[\"hangTime\"], Scouting[\"operationTime\"])","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:06.922641Z","iopub.execute_input":"2021-10-22T07:39:06.923006Z","iopub.status.idle":"2021-10-22T07:39:07.222949Z","shell.execute_reply.started":"2021-10-22T07:39:06.922976Z","shell.execute_reply":"2021-10-22T07:39:07.222303Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.scatterplot(Scouting[\"hangTime\"], Scouting[\"operationTime\"], hue = Scouting[\"snapDetail\"])","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:07.224032Z","iopub.execute_input":"2021-10-22T07:39:07.224350Z","iopub.status.idle":"2021-10-22T07:39:07.908366Z","shell.execute_reply.started":"2021-10-22T07:39:07.224323Z","shell.execute_reply":"2021-10-22T07:39:07.907490Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Possible values for kickoff plays:\n### D: Deep - your normal deep kick with decent hang time\n### F: Flat - different than a Squib in that it will have some hang time and no roll but has a lower trajectory and hang time than a Deep kick off\n### K: Free Kick - Kick after a safety\n### O: Obvious Onside - score and situation dictates the need to regain possession. Also the hands team is on for the returning team\n### P: Pooch kick - high for hangtime but not a lot of distance - usually targeting an upman\n### Q: Squib - low-line drive kick that bounces or rolls considerably, with virtually no hang time\n### S: Surprise Onside - accounting for score and situation an onsides kick that the returning team doesn’t expect. Hands teams probably aren't on the field\n### B: Deep Direct OOB - Kickoff that is aimed deep (regular kickoff) that goes OOB directly (doesn't bounce)\n\n# Possible values for punt plays:\n### N: Normal - standard punt style\n### R: Rugby style punt\n### A: Nose down or Aussie-style punts","metadata":{}},{"cell_type":"code","source":"kick_typ = Scouting[\"kickType\"].value_counts().reset_index()\nkick_typ.rename(columns = {'index' : 'Type_of_kick', 'kickType' : 'Count'}, inplace=True)","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:07.909575Z","iopub.execute_input":"2021-10-22T07:39:07.909807Z","iopub.status.idle":"2021-10-22T07:39:07.918511Z","shell.execute_reply.started":"2021-10-22T07:39:07.909778Z","shell.execute_reply":"2021-10-22T07:39:07.917655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.pie(kick_typ, values='Count', names='Type_of_kick', title='count of Kick Type')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-22T07:39:07.919592Z","iopub.execute_input":"2021-10-22T07:39:07.919829Z","iopub.status.idle":"2021-10-22T07:39:07.969625Z","shell.execute_reply.started":"2021-10-22T07:39:07.919805Z","shell.execute_reply":"2021-10-22T07:39:07.968733Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}