{"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":"markdown","source":"# Introduction\nThe NFL is America's most popular sports league. Founded in 1920, the organization behind American football has developed the model for the successful modern sports league. They're committed to advancing every aspect of the game, including the lesser researched special teams. In this competition, you’ll quantify team or individual strategies, rank players, or even something we haven’t considered.\n\nWith your creativity and analytical skills, the development of these new methods could lead to additional stats for special teams plays.\n\nReferences Notebooks: \n* https://www.kaggle.com/werooring/nfl-big-data-bowl-basic-eda-for-beginner\n* https://www.kaggle.com/travistyler/nfl-special-teams-eda\n* https://www.kaggle.com/bcruise/nfl-kickoff-returns-eda\n* https://www.kaggle.com/hijest/nfl-big-data-bowl-2022-starters-eda","metadata":{}},{"cell_type":"code","source":"# General Libraries\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport os # General OS properties\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# Plotting Libraries\nimport seaborn as sns\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:46.791131Z","iopub.execute_input":"2021-10-25T11:26:46.791661Z","iopub.status.idle":"2021-10-25T11:26:47.701075Z","shell.execute_reply.started":"2021-10-25T11:26:46.791625Z","shell.execute_reply":"2021-10-25T11:26:47.700201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Reperesentation\n* **Game Data:** The **games.csv** contains the teams playing in each game. The key variable is **gameId**.\n* **Play Data:** The **plays.csv** file contains play-level information from each game. The key variables are **gameId** and **playId**.\n* **Player 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* **Tracking Data:** Files tracking **season.csv** contain player tracking data from season **[season]**. The key variables are **gameId**, **playId**, and **nflId**.\n* **PFF 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":"# Read the Major data files for representation\n\ndf_games = pd.read_csv(\"../input/nfl-big-data-bowl-2022/games.csv\")\ndf_plays = pd.read_csv(\"../input/nfl-big-data-bowl-2022/plays.csv\")\ndf_players = pd.read_csv(\"../input/nfl-big-data-bowl-2022/players.csv\")\ndf_ppfSctdata = pd.read_csv(\"../input/nfl-big-data-bowl-2022/PFFScoutingData.csv\")","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:47.816293Z","iopub.execute_input":"2021-10-25T11:26:47.81687Z","iopub.status.idle":"2021-10-25T11:26:48.050712Z","shell.execute_reply.started":"2021-10-25T11:26:47.816838Z","shell.execute_reply":"2021-10-25T11:26:48.049973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Deatils of Game Data\n* **gameId**: Game identifier, unique (numeric)\n* **season**: Season of game\n* **week**: Week of game\n* **gameDate**: Game Date (time, mm/dd/yyyy)\n* **gameTimeEastern**: Start time of game (time, HH:MM:SS, EST)\n* **homeTeamAbbr**: Home team three-letter code (text)\n* **visitorTeamAbbr**: Visiting team three-letter code (text)","metadata":{}},{"cell_type":"code","source":"# Glimpse of Game data\ndf_games.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:48.734657Z","iopub.execute_input":"2021-10-25T11:26:48.735449Z","iopub.status.idle":"2021-10-25T11:26:48.76262Z","shell.execute_reply.started":"2021-10-25T11:26:48.735402Z","shell.execute_reply":"2021-10-25T11:26:48.761995Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Games data set information in brief\ndf_games.info()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:49.246455Z","iopub.execute_input":"2021-10-25T11:26:49.247322Z","iopub.status.idle":"2021-10-25T11:26:49.26683Z","shell.execute_reply.started":"2021-10-25T11:26:49.247276Z","shell.execute_reply":"2021-10-25T11:26:49.265904Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Augment the Games data related to Day, Week & Year\n\ndf_games[\"gameDate\"] = pd.to_datetime(df_games[\"gameDate\"])\ndf_games['mnthByYear'] = df_games[\"gameDate\"].dt.month_name()\ndf_games['dByWeek'] = df_games[\"gameDate\"].dt.day_name()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:49.75712Z","iopub.execute_input":"2021-10-25T11:26:49.757735Z","iopub.status.idle":"2021-10-25T11:26:49.769194Z","shell.execute_reply.started":"2021-10-25T11:26:49.757699Z","shell.execute_reply":"2021-10-25T11:26:49.768551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plot the Number Games / Year in respective Season on MOnthly Basis\n\nsns.set_style(\"whitegrid\")\nplt.figure(figsize=(8, 6))\nax = plt.gca()\n\nsns.countplot(x='season', data=df_games, hue='mnthByYear', lw=2, ec='black', ax=ax).set(title='Number of Games in a Season on Monthly basis')\nax.legend(loc='center right', bbox_to_anchor=(1.5, 0.5), ncol=1)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:50.268932Z","iopub.execute_input":"2021-10-25T11:26:50.269186Z","iopub.status.idle":"2021-10-25T11:26:50.569644Z","shell.execute_reply.started":"2021-10-25T11:26:50.269152Z","shell.execute_reply":"2021-10-25T11:26:50.568975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plot the Number Games / Year in respective Season on Waeekday Basis\n\nsns.set_style(\"whitegrid\")\nplt.figure(figsize=(8, 6))\nax = plt.gca()\n\nsns.countplot(x='season', data=df_games, hue='dByWeek', lw=2, ec='black', ax=ax).set(title='Number of Games in a Season on Weekday basis')\nax.legend(loc='center right', bbox_to_anchor=(1.5, 0.5), ncol=1)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:50.679719Z","iopub.execute_input":"2021-10-25T11:26:50.680041Z","iopub.status.idle":"2021-10-25T11:26:50.965238Z","shell.execute_reply.started":"2021-10-25T11:26:50.68001Z","shell.execute_reply":"2021-10-25T11:26:50.964589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Details from : Home team with respect to Visitor Team\n\nhTeamVsvTeam = df_games.groupby(['homeTeamAbbr', 'visitorTeamAbbr'], as_index=False).count()\nplt.figure(figsize=(15, 10))\nsns.set_style('dark')\n\nax = sns.swarmplot(data=hTeamVsvTeam, x=\"homeTeamAbbr\", y=\"visitorTeamAbbr\", hue=\"season\").set(title='Home Team with respect to Visitor Team')","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:51.106572Z","iopub.execute_input":"2021-10-25T11:26:51.107198Z","iopub.status.idle":"2021-10-25T11:26:56.592323Z","shell.execute_reply.started":"2021-10-25T11:26:51.107167Z","shell.execute_reply":"2021-10-25T11:26:56.59162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Games details with respect to Time (EST)\n\nsns.set_style(\"whitegrid\")\nplt.figure(figsize=(15, 10))\nax = plt.gca()\n\nsns.countplot(x='season', data=df_games, hue='gameTimeEastern', lw=2, ec='black', ax=ax).set(title='Game details in a Season on Time (EST) basis')\nax.legend(loc='center right', bbox_to_anchor=(1.5, 0.5), ncol=1)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:56.593615Z","iopub.execute_input":"2021-10-25T11:26:56.593864Z","iopub.status.idle":"2021-10-25T11:26:57.124779Z","shell.execute_reply.started":"2021-10-25T11:26:56.593831Z","shell.execute_reply":"2021-10-25T11:26:57.123974Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Details of Play Data\n* **gameId**: Game identifier, unique (numeric)\n* **playId**: Play identifier, not unique across games (numeric)\n* **playDescription**: Description of play (text)\n* **quarter**: Game quarter (numeric)\n* **down**: Down (numeric)\n* **yardsToGo**: Distance needed for a first down (numeric)\n* **possessionTeam**: Team punting, placekicking or kicking off the ball (text)\n* **specialTeamsPlayType**: Formation of play: Extra Point, Field Goal, Kickoff or Punt (text)\n* **specialTeamsPlayResult**: Special Teams outcome of play dependent on play type: Blocked Kick Attempt, Blocked Punt, Downed, Fair Catch, Kick Attempt Good, Kick Attempt No Good, Kickoff Team Recovery, Muffed, Non-Special Teams Result, Out of Bounds, Return or Touchback (text)\n* **kickerId**: nflId of placekicker, punter or kickoff specialist on play (numeric)\n* **returnerId**: nflId(s) of returner(s) on play if there was a special teams return. Multiple returners on a play are separated by a ; (text)\n* **kickBlockerId**: nflId of blocker of kick on play if there was a blocked field goal or blocked punt (numeric)\n* **yardlineSide**: 3-letter team code corresponding to line-of-scrimmage (text)\n* **yardlineNumber**: Yard line at line-of-scrimmage (numeric)\n* **gameClock**: Time on clock of play (MM:SS)\n* **penaltyCodes**: NFL categorization of the penalties that occurred on the play. Multiple penalties on a play are separated by a ; (text)\n* **penaltyJerseyNumber**: Jersey number and team code of the player committing each penalty.\n* **Multiple** penalties on a play are separated by a ; (text)\n* **penaltyYards**: yards gained by possessionTeam by penalty (numeric)\n* **preSnapHomeScore**: Home score prior to the play (numeric)\n* **preSnapVisitorScore**: Visiting team score prior to the play (numeric)\n* **passResult**: Scrimmage outcome of the play if specialTeamsPlayResult is \"Non-Special Teams Result\" (**C:** Complete pass, **I:** Incomplete pass, **S:** Quarterback sack, **IN:** Intercepted pass, **R:** Scramble, **' ':** Designed Rush, text)\n* **kickLength**: Kick length in air of kickoff, field goal or punt (numeric)\n* **kickReturnYardage**: Yards gained by return team if there was a return on a kickoff or punt (numeric)\n* **playResult**: Net yards gained by the kicking team, including penalty yardage (numeric)\n* **absoluteYardlineNumber**: Location of ball downfield in tracking data coordinates (numeric)","metadata":{}},{"cell_type":"code","source":"# Glimpse of Play data\ndf_plays.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:57.125923Z","iopub.execute_input":"2021-10-25T11:26:57.126282Z","iopub.status.idle":"2021-10-25T11:26:57.159428Z","shell.execute_reply.started":"2021-10-25T11:26:57.12622Z","shell.execute_reply":"2021-10-25T11:26:57.158715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Plays data set information in brief\ndf_plays.info()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:57.161765Z","iopub.execute_input":"2021-10-25T11:26:57.162181Z","iopub.status.idle":"2021-10-25T11:26:57.192764Z","shell.execute_reply.started":"2021-10-25T11:26:57.162148Z","shell.execute_reply":"2021-10-25T11:26:57.191973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# In play data set vrious fields contains \"NaN\" vlaues but still I am plotting these fields \n# without implementing any feature engineering.\n\nfig, ((ax1,ax2),(ax3,ax4),(ax5,ax6),(ax7,ax8), (ax9,ax10)) = plt.subplots(5,2, figsize=(15,20))\n\nsns.histplot(data=df_plays, x=\"kickLength\", bins=50, kde=True, ax=ax1).set(title='Kick Length (Yards)')\nsns.histplot(data=df_plays, x=\"kickReturnYardage\", bins=50, kde=True, ax=ax2).set(title='Kick Return Length (Yards)')\n\nsns.histplot(data=df_plays, x=\"playResult\", bins=50, kde=True, ax=ax3).set(title='Net Distance Gained (Yards)')\nsns.histplot(data=df_plays, x=\"yardsToGo\", bins=50, kde=True, ax=ax4).set(title='First Down Distance (Yards)')\n\nsns.histplot(data=df_plays, x=\"penaltyYards\", bins=50, kde=True, ax=ax5).set(title='Possesion Team gained Distance by Penalty (Yards)')\nsns.histplot(data=df_plays, x=\"penaltyCodes\", bins=50, kde=True, ax=ax6).set(title='NFL Penalty Categorization')\n\nsns.histplot(data=df_plays, x=\"specialTeamsPlayType\", bins=50, kde=True, ax=ax7).set(title='Formation of Play')\nsns.histplot(data=df_plays, x=\"specialTeamsResult\", bins=50, kde=True, ax=ax8).set(title='Results of Special Team Play')\n\nsns.histplot(data=df_plays, x=\"passResult\", bins=50, kde=True, ax=ax9).set(title='Scrimmage Outcome')\nsns.histplot(data=df_plays, x=\"yardlineNumber\", bins=50, kde=True, ax=ax10).set(title='Line Of Scrimmage')\n\nplt.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:26:57.194069Z","iopub.execute_input":"2021-10-25T11:26:57.19439Z","iopub.status.idle":"2021-10-25T11:27:03.923721Z","shell.execute_reply.started":"2021-10-25T11:26:57.194353Z","shell.execute_reply":"2021-10-25T11:27:03.922086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Details of Players Data\n* **gameId**: Game identifier, unique (numeric)\n* **playId**: Play identifier, not unique across games (numeric)\n* **nflId**: Player identification number, unique across players (numeric)\n* **Height**: Player height (text)\n* **Weight**: Player weight (numeric)\n* **birthDate**: Date of birth (YYYY-MM-DD)\n* **collegeName**: Player college (text)\n* **Position**: Player position (text)\n* **displayName**: Player name (text)","metadata":{}},{"cell_type":"code","source":"# Glimpse of Players data\ndf_players.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:03.925058Z","iopub.execute_input":"2021-10-25T11:27:03.925662Z","iopub.status.idle":"2021-10-25T11:27:03.940321Z","shell.execute_reply.started":"2021-10-25T11:27:03.925623Z","shell.execute_reply":"2021-10-25T11:27:03.939556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Players data set information in brief\ndf_players.info()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:03.942285Z","iopub.execute_input":"2021-10-25T11:27:03.943117Z","iopub.status.idle":"2021-10-25T11:27:03.960205Z","shell.execute_reply.started":"2021-10-25T11:27:03.94307Z","shell.execute_reply":"2021-10-25T11:27:03.959464Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Height Column\nHeight column of the need to be modified and stored in the form of height feet with decimal placces properly.","metadata":{}},{"cell_type":"code","source":"# Spilt the data of the cell with token '-'\ncheck = df_players['height'].str.split('-', expand=True)\n\n# Store the splitted data into list with \"decimal\" & \ncheck.columns = ['integer', 'fraction']\n\n# Check the fraction & integer part\ncheck.loc[(check['fraction'].notnull()), 'integer'] = check[check['fraction'].notnull()]['integer'].astype(np.int16) * 12 + check[check['fraction'].notnull()]['fraction'].astype(np.int16)\n\n# Store the updated height value.\ndf_players['height'] = check['integer']\ndf_players['height'] = df_players['height'].astype(np.float32)\ndf_players['height'] /= 12","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:03.961535Z","iopub.execute_input":"2021-10-25T11:27:03.962175Z","iopub.status.idle":"2021-10-25T11:27:04.089682Z","shell.execute_reply.started":"2021-10-25T11:27:03.962138Z","shell.execute_reply":"2021-10-25T11:27:04.088837Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Display data after column updation\ndf_players.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:04.090871Z","iopub.execute_input":"2021-10-25T11:27:04.091625Z","iopub.status.idle":"2021-10-25T11:27:04.106905Z","shell.execute_reply.started":"2021-10-25T11:27:04.091589Z","shell.execute_reply":"2021-10-25T11:27:04.106055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Create separate column for Birth Year\ndf_players['birthYear'] = 0\n\n# If there NA for bith year, Drop those values\ndf_players.dropna(subset=['birthDate'], inplace=True)\n\n# Extract the birth year - From DOB column\nfor idx, row in df_players.iterrows():\n    if len(row['birthDate'].split('/')) == 3: \n        df_players.loc[idx, 'birthYear'] = row['birthDate'].split('/')[2]\n        \n    elif len(row['birthDate'].split('-')) == 3:\n        df_players.loc[idx, 'birthYear'] = row['birthDate'].split('-')[0]","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:04.108213Z","iopub.execute_input":"2021-10-25T11:27:04.108953Z","iopub.status.idle":"2021-10-25T11:27:05.124224Z","shell.execute_reply.started":"2021-10-25T11:27:04.108914Z","shell.execute_reply":"2021-10-25T11:27:05.123219Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Display the players data in segmented cells\nfig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(2,2, figsize=(10,10))\n\nax = sns.histplot(df_players['height'], bins=50, kde=True, ax=ax1).set(title='Height Distribution')\nax = sns.histplot(df_players['weight'], bins=50, kde=True, ax=ax2).set(title='Weight Distribution')\n\nax = sns.histplot(df_players['birthYear'], bins=50, kde=True, ax=ax3).set(title='Players with respect to Birth Year')\nax = sns.histplot(df_players['nflId'], bins=50, kde=True, ax=ax4).set(title='Player Identification')\n\nplt.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:05.125609Z","iopub.execute_input":"2021-10-25T11:27:05.125882Z","iopub.status.idle":"2021-10-25T11:27:07.171275Z","shell.execute_reply.started":"2021-10-25T11:27:05.125848Z","shell.execute_reply":"2021-10-25T11:27:07.170574Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# PFF Scouting data\n* **gameId**: Game identifier, unique (numeric)\n* **playId**: Play identifier, not unique across games (numeric)\n* **snapDetail**: Punts Detail (H: High, L: Low, <: Left,>: Right, OK: Accurate Snap, text)\n* **operationTime**: Timing from snap to kick on punt plays in seconds: (numeric)\n* **hangTime**: Hangtime of player's punt or kickoff attempt in seconds. (numeric)\n* **kickType**: Kickoff or Punt Type (text).\n* 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* Possible values for punt plays:\n  * N: Normal - standard punt style\n  * R: Rugby style punt\n  * A: Nose down or Aussie-style punts\n* **kickDirectionIntended**: Intended kick direction from the kicking team's perspective - based on how coverage unit sets up and other factors (L: Left, R: Right, C: Center, text).\n* **kickDirectionActual**: Actual kick direction from the kicking team's perspective (L: Left, R: Right, C: Center, text).\n* **returnDirectionIntended**: The return direction the punt return or kick off return unit is set up for from the return team's perspective (L: Left, R: Right, C: Center, text).\n* **returnDirectionActual**: Actual return direction from the return team's perspective (L: Left, R: Right, C: Center, text).\n* **missedTacklers**: Jersey number and team code of player(s) charged with a missed tackle on the play. (text).\n* **assistTacklers**: Jersey number and team code of player(s) assisting on the tackle. Multiple assist tacklers on a play are separated by a ; (text).\n* **tacklers**: Jersey number and team code of player making the tackle (text).\n* **kickoffReturnFormation**: 3 digit code indicating the number of players in the Front Wall, Mid Wall and Back Wall (text).\n* **gunners**: Jersey number and team code of player(s) lined up as gunner on punt unit. Multiple gunners on a play are separated by a ; (text).\n* **puntRushers**: Jersey number and team code of player(s) on the punt return unit with \"Punt Rush\" role for actively trying to block the punt. (text).\n* **specialTeamsSafeties**: Jersey number and team code for player(s) with \"Safety\" roles on kickoff coverage and field goal/extra point block units - and those not actively advancing towards the line of scrimmage on the punt return unit. (text).\n* **vises**: Jersey number and team code for player(s) with a \"Vise\" role on the punt return unit. Multiple vises on a play are separated by a ; (text).\n* **kickContactType**: Detail on how a punt was fielded, or what happened when it wasn't fielded (text).\n* Possible values:\n  * BB: Bounced Backwards\n  * BC: Bobbled Catch from Air\n  * BF: Bounced Forwards\n  * BOG: Bobbled on Ground\n  * CC: Clean Catch from Air\n  * CFFG: Clean Field From Ground\n  * DEZ: Direct to Endzone\n  * ICC: Incidental Coverage Team Contact\n  * KTB: Kick Team Knocked Back\n  * KTC: Kick Team Catch\n  * KTF: Kick Team Knocked Forward\n  * MBC: Muffed by Contact with Non-Designated Returner\n  * MBDR: Muffed by Designated Returner\n  * OOB: Directly Out Of Bounds","metadata":{}},{"cell_type":"code","source":"# PPF Scounting Data \ndf_ppfSctdata.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:07.172333Z","iopub.execute_input":"2021-10-25T11:27:07.172716Z","iopub.status.idle":"2021-10-25T11:27:07.199889Z","shell.execute_reply.started":"2021-10-25T11:27:07.172681Z","shell.execute_reply":"2021-10-25T11:27:07.19916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Details information of PPF Scout data\ndf_ppfSctdata.info()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:27:07.201229Z","iopub.execute_input":"2021-10-25T11:27:07.201689Z","iopub.status.idle":"2021-10-25T11:27:07.235418Z","shell.execute_reply.started":"2021-10-25T11:27:07.20165Z","shell.execute_reply":"2021-10-25T11:27:07.23459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ((ax1,ax2),(ax3,ax4),(ax5,ax6)) = plt.subplots(3,2, figsize=(15,20))\n\nax = sns.histplot(df_ppfSctdata.hangTime, bins=20, kde=True, ax=ax1).set(title='Hangtime (seconds)')\nax = sns.histplot(df_ppfSctdata.loc[df_ppfSctdata.kickType.notnull()]['kickType'].value_counts(), bins=20, kde=True, ax=ax2).set(title='Kick Type')\n\nax = sns.histplot(df_ppfSctdata.loc[df_ppfSctdata.kickDirectionActual.notnull()]['kickDirectionActual'].value_counts(), bins=20, kde=True, ax=ax3).set(title='Kick Direction')\nax = sns.histplot(df_ppfSctdata.loc[df_ppfSctdata.snapTime.notnull()]['snapTime'], bins=20, kde=True, ax=ax4).set(title='Snap Time')\n\nax = sns.histplot(df_ppfSctdata.loc[df_ppfSctdata.kickContactType.notnull()]['kickContactType'].value_counts(), bins=20, kde=True, ax=ax5).set(title='Kick Contact Type')\nax = sns.histplot(df_ppfSctdata.loc[df_ppfSctdata.returnDirectionActual.notnull()]['returnDirectionActual'].value_counts(), bins=20, kde=True, ax=ax6).set(title='Return Direction')\n\nplt.tight_layout()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:44:51.937654Z","iopub.execute_input":"2021-10-25T11:44:51.937966Z","iopub.status.idle":"2021-10-25T11:44:54.452789Z","shell.execute_reply.started":"2021-10-25T11:44:51.937936Z","shell.execute_reply":"2021-10-25T11:44:54.452134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Merge scout and plays\nplay_scout = pd.merge(df_plays, df_ppfSctdata, how='left', on=['playId','gameId'])\n# Select only numeric columns\nnum_play_scout = play_scout.select_dtypes(include=['int','float'])\n\n\ncorr_df = num_play_scout[['quarter','down','yardsToGo','yardlineNumber',\n                          'penaltyYards','preSnapHomeScore','preSnapVisitorScore',\n                          'kickLength','kickReturnYardage','playResult',\n                          'absoluteYardlineNumber','snapTime','operationTime',\n                          'hangTime']]\n\nplt.figure(figsize=(20, 10))\ncorr = corr_df.corr()\nsns.heatmap(corr, annot=True)\nplt.title('Plays - Scout Data Correlation Heatmap')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:52:22.43246Z","iopub.execute_input":"2021-10-25T11:52:22.432726Z","iopub.status.idle":"2021-10-25T11:52:23.766237Z","shell.execute_reply.started":"2021-10-25T11:52:22.432697Z","shell.execute_reply":"2021-10-25T11:52:23.7652Z"},"trusted":true},"execution_count":null,"outputs":[]}]}