{"cells":[{"metadata":{"_uuid":"0fbd0cbad504c7f16fd70502f3a51846533d0b15"},"cell_type":"markdown","source":"   ## NFL RULE IMPROVEMENTS"},{"metadata":{"_uuid":"4dad2f896168c6370e2f7478755c0c90b999ea76"},"cell_type":"markdown","source":"**The National Football League is America's most popular sports league, comprised of 32 franchises that compete each year to win the Super Bowl, the world's biggest annual sporting event. Founded in 1920, the NFL developed the model for the successful modern sports league, including national and international distribution, extensive revenue sharing, competitive excellence, and strong franchises across the country.\n**\n**The NFL is committed to advancing progress in the diagnosis, prevention and treatment of sports-related injuries. The NFL's ongoing health and safety efforts include support for independent medical research and engineering advancements and a commitment to look at anything and everything to protect players and make the game safer, including enhancements to medical protocols and improvements to how our game is taught and played.**\n\n**As more is learned, the league evaluates and changes rules to evolve the game and try to improve protections for players. Since 2002 alone, the NFL has made 50 rules changes intended to eliminate potentially dangerous tactics and reduce the risk of injuries.**"},{"metadata":{"_uuid":"bdab0c59a654d9676b813c47048ca09359a1ac7e"},"cell_type":"markdown","source":"![](https://static.nfl.com/static/content/public/static/img/share/shield.jpg)"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-input":true,"_kg_hide-output":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)\nimport plotly.offline as py\nfrom plotly.offline import init_notebook_mode, iplot\nimport plotly.graph_objs as go\nfrom plotly import tools\ninit_notebook_mode(connected=True)  \nimport plotly.figure_factory as ff\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true,"_kg_hide-output":true,"_kg_hide-input":true},"cell_type":"code","source":"game_data = pd.read_csv('../input/NFL-Punt-Analytics-Competition/game_data.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"be81bdf2ea0de29e5f1444aaa89b0f64f006ae13","_kg_hide-output":true,"_kg_hide-input":true},"cell_type":"code","source":"\ngame_data.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5aae2240b6e175e9f830379dffe8796c11af8473","_kg_hide-input":true},"cell_type":"code","source":"import random\ndef random_colors(number_of_colors):\n    color = [\"#\"+''.join([random.choice('0123456789ABCDEF') for j in range(6)])\n                 for i in range(number_of_colors)]\n    return color","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2cb25cce676fdbf4b9ddf7ad2f20acfb9b608133","_kg_hide-input":true},"cell_type":"code","source":"game_data['Temperature']= game_data['Temperature'].fillna(game_data['Temperature'].mean())\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"35c74f7ee2023175422281158b205124d048304d","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"game_data.head()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8477bfc7f1a6d02bd9e2d6748172458bab5cc4e9"},"cell_type":"markdown","source":"# Season Temperature Analysis"},{"metadata":{"trusted":true,"_uuid":"585c5c9528b0049a47c554b2d1437208baed015a","_kg_hide-input":true},"cell_type":"code","source":"from datetime import datetime\nimport pandas_datareader.data as web\n\n\ndata = [go.Scatter(x=game_data.Game_Date, y=game_data.Temperature)]\n\npy.iplot(data)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d0c0073f5c5e76309017007a12343edcf91ad020"},"cell_type":"markdown","source":"**The temperature of the season varies from High 90s to low 00s as it goes real low during the winter season.**"},{"metadata":{"_uuid":"8368f35e9210e446260a912c9b68a9b8c41cb7a6"},"cell_type":"markdown","source":"# Most Played Game Venue during the 2016 NFL Season"},{"metadata":{"trusted":true,"_uuid":"62a547da342e733c589a88c6a2dc4196d4340d0f","_kg_hide-input":true},"cell_type":"code","source":"pitch_count = game_data['Game_Site'].value_counts()\ndata = [go.Bar(\n    x = pitch_count.index,\n    y = pitch_count.values,\n    marker = dict(color = random_colors(25))\n)]\nlayout = dict(\n         title= \"Most Occurring Game Venue \"\n)\nfig = dict( data=data, layout=layout )\niplot( fig, validate=False )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a0de4ee291a705e13a3ad433df91aa083a7a84fe"},"cell_type":"markdown","source":"**As it turns out East Rutherford site has seen 40 of the season's matches whereas Foxborough has seen 24 following by Atlanta Pittsburgh, Philadelphia e.t.c by 22.**"},{"metadata":{"_uuid":"b399197e5fa1fddbed886f599c726ac82eec9059"},"cell_type":"markdown","source":"**If you don't know about that game site then you should as it's home to New york Giants (Metlife Stadium).**"},{"metadata":{"_uuid":"f6a6bf06efb9f3d6711e22fd110b8f474f00327d"},"cell_type":"markdown","source":"![](https://media-cdn.tripadvisor.com/media/photo-s/0c/0c/d4/11/nfl.jpg)"},{"metadata":{"_uuid":"395b20279fcaf23f5391c208752e6d4f0d22e5f4"},"cell_type":"markdown","source":"# Most played day of the NFL season"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"1277def1dbab923862cda343bb8f8cf7e237eddb"},"cell_type":"code","source":"day_count = game_data['Game_Day'].value_counts()\ntrace = go.Pie(labels=day_count.index, values=day_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Game Day Percentage'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0ef9c3200549b7489be9edb800fe43ca1d864fe1"},"cell_type":"markdown","source":"**As i've expected most no of days belongs to the weekends, Sunday having 68% of all of game days.**"},{"metadata":{"_uuid":"a021dbc1c393411ec2db12a9ca00e924ff7c9e1c"},"cell_type":"markdown","source":"# Most Stadium's Type of the NFL Stadiums used"},{"metadata":{"trusted":true,"_uuid":"f474163f2495909b6659e82ce63c2d95414620a4","_kg_hide-input":true},"cell_type":"code","source":"pitch_count = game_data['StadiumType'].value_counts()\ndata = [go.Bar(\n    x = pitch_count.index,\n    y = pitch_count.values,\n    marker = dict(color = random_colors(25))\n)]\nlayout = dict(\n         title= \"Different types of Stadium\"\n)\nfig = dict( data=data, layout=layout )\niplot( fig, validate=False )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d6a3bd7e709d3de72babeb3a338c6ecf9bd369cb"},"cell_type":"markdown","source":"**There are lots of typing error in the data for the stadium type but if we add up the outdoor and outdoors as together it come out as 348+81= 429 something is the number of times outdoor stadium used in the whole season.**"},{"metadata":{"_uuid":"cfab08a915f3055257cab7277709f0a4e2a634e1"},"cell_type":"markdown","source":"![](http://footballstadiumdigest.com/wp-content/uploads/2015/11/new-atlanta-dec2015-4.jpg)"},{"metadata":{"_uuid":"3995eb14c8f273a65ba811cedf01422ec9eeb8c7"},"cell_type":"markdown","source":"**Mercedes Benz Stadium is the best stadium among the football stadium, it's architecture is flabbergasting.**"},{"metadata":{"_uuid":"b5f6ff6d99945b1c66fec8333223ee64a4eacc86"},"cell_type":"markdown","source":"# Weather of the whole season "},{"metadata":{"trusted":true,"_uuid":"916974f5ea1324715b995e91e3b0b7cb064046ca","_kg_hide-input":true},"cell_type":"code","source":"pitch_count = game_data['GameWeather'].value_counts()\ndata = [go.Bar(\n    x = pitch_count.index,\n    y = pitch_count.values,\n    marker = dict(color = random_colors(25))\n)]\nlayout = dict(\n         title= \"Different types of Weathers\"\n)\nfig = dict( data=data, layout=layout )\niplot( fig, validate=False )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ace581530c5bacdd3fd6af1d57c1ff81991b0acd"},"cell_type":"markdown","source":"**Sunny weather has been very kind to the most of nfl matches with 145 times whereas partly Cloudy has been 119 times.**"},{"metadata":{"_uuid":"478b9ca59663f8d896249e1b5a8803c8f90e09b1"},"cell_type":"markdown","source":"# Turf on which most NFL games played in"},{"metadata":{"trusted":true,"_uuid":"1940d7338e3d0ee4c824a8fa930d50b6b0333721","_kg_hide-input":true},"cell_type":"code","source":"pitch_count = game_data['Turf'].value_counts()\ndata = [go.Bar(\n    x = pitch_count.index,\n    y = pitch_count.values,\n    marker = dict(color = random_colors(25))\n)]\nlayout = dict(\n         title= \"Different types of Turfs\"\n)\nfig = dict( data=data, layout=layout )\niplot( fig, validate=False )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"3314ab56da005656089eabefef2101c43c5f7ce0"},"cell_type":"code","source":"video_review= pd.read_csv('../input/NFL-Punt-Analytics-Competition/video_review.csv')\nvideo_review.head()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"c3f82aca019618c1c674e19308e4d8a7e0589b10"},"cell_type":"markdown","source":"**As any NFL player would have wanted the turfs to be grass so less injury prone incidents.**"},{"metadata":{"_uuid":"79aa73b751aca3c5fb985fd5925aaddcfadb4873"},"cell_type":"markdown","source":"![](https://www.independentcollection.com/wp-content/uploads/2016/10/iStock_42500060_SMALL.jpg)"},{"metadata":{"trusted":true,"_uuid":"77abcde20473b5a14ae56090e5d7cd92ee71895f","_kg_hide-input":true},"cell_type":"code","source":"NGS= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2016-post.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0a62b30512f388a92238009b4a0fd33bcff1e6a4","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"NGS.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5fd150a81d25074f2a5d5a932ea29021e95dd1bf","_kg_hide-input":true},"cell_type":"code","source":"NGS = NGS.fillna(0)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a1660262e38a7be4042e69e06dab114ed486044c","_kg_hide-input":true},"cell_type":"code","source":"NGS1= NGS.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7aab8ef85a445be2858c9b94da1e618525f48524","_kg_hide-input":true},"cell_type":"code","source":"import base64\nwith open(\"../input/picture2/61jq6q0FyJL._SY606_.jpg\", \"rb\") as image_file:\n    encoded_string = base64.b64encode(image_file.read()).decode()\n#add the prefix that plotly will want when using the string as source\nencoded_image = \"data:image/png;base64,\" + encoded_string","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"89618968bcd10e69ffdddcc672cc0eb662806501"},"cell_type":"markdown","source":"# Analysis of NFL Next Gen Stats Week and season wise"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"aecd49a8b6e4f95475fff0d4e984003302156b57"},"cell_type":"code","source":"def convert_to_mph(dis, converter):\n    mph = dis * converter\n    return mph","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f33580bbb4a5c7ffb51c02a9887eb73c8676a918"},"cell_type":"code","source":"def get_speed(ng_data, playId, gameKey, player, partner):\n    ng_data = pd.read_csv(ng_data,low_memory=False)\n    ng_data['mph'] = convert_to_mph(ng_data['dis'], 20.455)\n    player_data = ng_data.loc[(ng_data.GameKey == gameKey) & (ng_data.PlayID == playId) \n                               & (ng_data.GSISID == player)].sort_values('Time')\n    partner_data = ng_data.loc[(ng_data.GameKey == gameKey) & (ng_data.PlayID == playId) \n                              & (ng_data.GSISID == partner)].sort_values('Time')\n    player_grouped = player_data.groupby(['GameKey','PlayID','GSISID'], \n                               as_index = False)['mph'].agg({'max_mph': max,\n                                                             'avg_mph': np.mean\n                                                            })\n    player_grouped['Player_Involved'] = 'player_injured'\n    partner_grouped = partner_data.groupby(['GameKey','PlayID','GSISID'], \n                               as_index = False)['mph'].agg({'max_mph': max,\n                                                             'avg_mph': np.mean\n                                                            })\n    partner_grouped['Player_Involved'] = 'primary_partner'\n    return pd.concat([player_grouped, partner_grouped], axis = 0)[['Player_Involved',\n                                                                   'max_mph',\n                                                                   'avg_mph']].reset_index(drop=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"8f00f2f68ac5f10224a5d87ec7a4ab71a9add2ce"},"cell_type":"code","source":"def load_layout():\n    \"\"\"\n    Returns a dict for a Football themed Plot.ly layout \n    \"\"\"\n    layout = dict(\n        title = \"Player Activity\",\n        plot_bgcolor='darkseagreen',\n        showlegend=True,\n        xaxis=dict(\n            autorange=False,\n            range=[0, 120],\n            showgrid=False,\n            zeroline=False,\n            showline=True,\n            linecolor='black',\n            linewidth=1,\n            mirror=True,\n            ticks='',\n            tickmode='array',\n            tickvals=[10,20, 30, 40, 50, 60, 70, 80, 90, 100, 110],\n            ticktext=['Goal', 10, 20, 30, 40, 50, 40, 30, 20, 10, 'Goal'],\n            showticklabels=True\n        ),\n        yaxis=dict(\n            title='',\n            autorange=False,\n            range=[-3.3,56.3],\n            showgrid=False,\n            zeroline=False,\n            showline=True,\n            linecolor='black',\n            linewidth=1,\n            mirror=True,\n            ticks='',\n            showticklabels=False\n        ),\n        shapes=[\n            dict(\n                type='line',\n                layer='below',\n                x0=0,\n                y0=0,\n                x1=120,\n                y1=0,\n                line=dict(\n                    color='white',\n                    width=2\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=0,\n                y0=53.3,\n                x1=120,\n                y1=53.3,\n                line=dict(\n                    color='white',\n                    width=2\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=10,\n                y0=0,\n                x1=10,\n                y1=53.3,\n                line=dict(\n                    color='white',\n                    width=10\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=20,\n                y0=0,\n                x1=20,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=30,\n                y0=0,\n                x1=30,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=40,\n                y0=0,\n                x1=40,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=50,\n                y0=0,\n                x1=50,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=60,\n                y0=0,\n                x1=60,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),dict(\n                type='line',\n                layer='below',\n                x0=70,\n                y0=0,\n                x1=70,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),dict(\n                type='line',\n                layer='below',\n                x0=80,\n                y0=0,\n                x1=80,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=90,\n                y0=0,\n                x1=90,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),dict(\n                type='line',\n                layer='below',\n                x0=100,\n                y0=0,\n                x1=100,\n                y1=53.3,\n                line=dict(\n                    color='white'\n                )\n            ),\n            dict(\n                type='line',\n                layer='below',\n                x0=110,\n                y0=0,\n                x1=110,\n                y1=53.3,\n                line=dict(\n                    color='white',\n                    width=10\n                )\n            )\n        ]\n    )\n    return layout\n\nlayout = load_layout()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f56f454292ecb072a12fb3fa21a5fb764470aad5","_kg_hide-input":true},"cell_type":"code","source":"Player_position= go.Scatter(x=NGS1.x,y=NGS1.y)\n\nfig=go.Figure(data=[Player_position],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"5a5ab0f10c78d4d276acb3ca4707b3a5752732b2"},"cell_type":"markdown","source":"**Position analysis of players during 1000 plays of 2016 Post season matches **"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"1ce5ee1b4e585bf7ba19a93896341e9855d31fc6"},"cell_type":"code","source":"# Loading and plotting functions\n\ndef load_plays_for_game(GameKey):\n    \"\"\"\n    Returns a dataframe of play data for a given game (GameKey)\n    \"\"\"\n    play_information = pd.read_csv('../input/NFL-Punt-Analytics-Competition/play_information.csv')\n    play_information = play_information[play_information['GameKey'] == GameKey]\n    return play_information\n\n\ndef load_game_and_ngs(ngs_file=None, GameKey=None):\n    \"\"\"\n    Returns a dataframe of player movements (NGS data) for a given game\n    \"\"\"\n    if ngs_file is None:\n        print(\"Specifiy an NGS file.\")\n        return None\n    if GameKey is None:\n        print('Specify a GameKey')\n        return None\n    # Merge play data with NGS data    \n    plays = load_plays_for_game(GameKey)\n    ngs = pd.read_csv(ngs_file, low_memory=False)\n    merged = pd.merge(ngs, plays, how=\"inner\", on=[\"GameKey\", \"PlayID\", \"Season_Year\"])\n    return merged\n\n\ndef plot_play(game_df, PlayID, player1=None, player2=None, custom_layout=False):\n    \"\"\"\n    Plots player movements on the field for a given game, play, and two players\n    \"\"\"\n    game_df = game_df[game_df.PlayID==PlayID]\n    \n    GameKey=str(pd.unique(game_df.GameKey)[0])\n    HomeTeam = pd.unique(game_df.Home_Team_Visit_Team)[0].split(\"-\")[0]\n    VisitingTeam = pd.unique(game_df.Home_Team_Visit_Team)[0].split(\"-\")[1]\n    YardLine = game_df[(game_df.PlayID==PlayID) & (game_df.GSISID==player1)]['YardLine'].iloc[0]\n    \n    traces=[]   \n    if (player1 is not None) & (player2 is not None):\n        game_df = game_df[ (game_df['GSISID']==player1) | (game_df['GSISID']==player2)]\n        for player in pd.unique(game_df.GSISID):\n            player = int(player)\n            trace = go.Scatter(\n                x = game_df[game_df.GSISID==player].x,\n                y = game_df[game_df.GSISID==player].y,\n                name='GSISID '+str(player),\n                mode='markers'\n            )\n            traces.append(trace)\n    else:\n        print(\"Specify GSISIDs for player1 and player2\")\n        return None\n    \n    if custom_layout is not True:\n        layout = load_layout()\n        layout['title'] =  HomeTeam + \\\n        ' vs. ' + VisitingTeam + \\\n        '<br>Possession: ' + \\\n        YardLine.split(\" \")[0] +'@'+YardLine.split(\" \")[1]\n    data = traces\n    fig = dict(data=data, layout=layout)\n    play_description = game_df[(game_df.PlayID==PlayID) & (game_df.GSISID==player1)].iloc[0][\"PlayDescription\"]\n    print(\"\\n\\n\\t\",play_description)\n    offline.iplot(fig, config=config)\n    \n","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f26135da7feee7760d96884edb0300f705bafac6"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS, on=['Season_Year','GameKey','PlayID','GSISID'])","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"7123912bc7155f06c8a8e6a20a3d22f465c376a7"},"cell_type":"code","source":"video_review1","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"22200e42512c5c9074173d121003f28d26ee4e01"},"cell_type":"code","source":"import glob\nfrom plotly import offline\nimport plotly.graph_objs as go\n\n\npd.set_option('max.columns', None)\noffline.init_notebook_mode()\nconfig = dict(showLink=False)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"cd60d57dd9b6023cf49aa8afebfbdec93316bc33"},"cell_type":"markdown","source":"# **No concussion incident happened during 2016 post season matches.**"},{"metadata":{"_uuid":"b17e253f487fc096737a87f66b5925c93e378f9a"},"cell_type":"markdown","source":"# **Let's analyse all 37 cases and the player and primary partner's movement which lead to concussion**"},{"metadata":{"_uuid":"1684064c85ab71bcb083b654d1f1b26532e67d38"},"cell_type":"markdown","source":"# Pre Season Analysis of 2016 NFL Matches"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"a61d0866dd532c305c4784274f57e05ab01f9494"},"cell_type":"code","source":"NGS_pre= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv')\nNGS_pre.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3071901d55ebd874da1b1aff54afc308b537609e"},"cell_type":"code","source":"NGS_pre1= NGS_pre.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"ad9b688d666ab05bec771aa8441fa785ec5f0690"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_pre1.x,y=NGS_pre1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ea23d5bbb27d33d943db2c0384f711e1e9342e7b"},"cell_type":"markdown","source":"**Position analysis of play during 2016 Pre season matches **"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"0bac2d48ac052ce1218e69c511d18db8404741bf"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_pre, on=['Season_Year','GameKey','PlayID','GSISID'])","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"0a48d3563bae55dee3cf6eb6b98090657cb97a24"},"cell_type":"code","source":"video_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"b0e399443a41d3d6dade5b87d8791feedadf0894"},"cell_type":"code","source":"game5 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv',GameKey=5)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"a12f8ecf51b1eda714d991ea4f358dbfb05c9c25"},"cell_type":"code","source":"game21 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv',GameKey=21)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3ac37b749d50e7022b61e6b92a367ba336b5e9a1"},"cell_type":"code","source":"game29 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv',GameKey=29)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bceac716e3d109fd810b9aa50fd8da4e37cbe480","_kg_hide-input":true},"cell_type":"code","source":"game45 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv',GameKey=45)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6971614dd470227957f7ab73126672f49dca5618","_kg_hide-input":true},"cell_type":"code","source":"game54 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv',GameKey=54)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3c7fc474387e63742991ef9e556752fd914fed8f"},"cell_type":"code","source":"game60 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv',GameKey=60)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"4506959bb0f3fa8e4381339b1bfbc9f0747edd79"},"cell_type":"markdown","source":"# **Player and their Primary Partner's  Movement during the play which lead to concussion **"},{"metadata":{"trusted":true,"_uuid":"f14c2d9c9168824b97624287d25c548d1c184cff","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv', 3129, 5, 31057, 32482))\nplot_play(game_df=game5, PlayID=3129, player1=31057, player2=32482 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"afa6086ff5d2851f11b4eb77f629839bb18a95e0"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv', 2587, 21, 29343, 31059))\nplot_play(game_df=game21, PlayID=2587, player1=29343, player2=31059 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f11b1be8c06853a7192eb48855ab5ca69c77fe51"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv', 538, 29, 31023, 31941))\nplot_play(game_df=game29, PlayID=538, player1=31023, player2=31941 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"8d522baaff8616269b6fbfd5d0ef281c5f31c27f"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[3][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[3][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[3][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[3][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv', 1212, 45, 33121, 28429))\nplot_play(game_df=game45, PlayID=1212, player1=33121, player2=28429 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"926bcd104f2a3cf2890598ed6a6c82439f698406"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[4][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[4][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[4][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[4][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv', 1045, 54, 32444, 31756))\nplot_play(game_df=game54, PlayID=1045, player1=32444, player2=31756 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"602b9e05827fe36e5c2ed3ecd2ab63a14a3ea26c"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[5][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[5][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[5][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[5][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-pre.csv', 905, 60, 30786, 29815))\nplot_play(game_df=game60, PlayID=905, player1=30786, player2=29815 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"997f70b22cdb35f8ce9a5dfaab3efbeda205f3cd"},"cell_type":"markdown","source":"# Regular Weekly Play Analysis from Week 1 - 6 "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"ba84fec05267d97addcb58539c2e312c25aa17a1"},"cell_type":"code","source":"NGS_reg= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk1-6.csv')\nNGS_reg.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"336accd80d26b78ead28d5bfafa1559aac80a05b"},"cell_type":"code","source":"NGS_reg1= NGS_reg.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"154846aaf3ba94a98b35132e9ee44cfd2b8a56e8"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_reg1.x,y=NGS_reg1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"1cba3c59940c037aaa044c8e85bc955433fd7c6b"},"cell_type":"markdown","source":"**Position analysis of play during 2016 Weekly season matches **"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"7fe01ffc1446daea164f676b948856464b55e80d"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_reg, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"2c1f65ef892dbc978be5aa9dfe160c975749983d"},"cell_type":"code","source":"game149 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk1-6.csv',GameKey=149)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"1f510e497b76ab2d66716c1ef8b142fd1e39f4df"},"cell_type":"code","source":"game144 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk1-6.csv',GameKey=144)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"95d80013ebdea9de307a57dabee5374d3d7ca529"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk1-6.csv', 2342, 144, 32410, 23259))\nplot_play(game_df=game144, PlayID=2342, player1=32410, player2=23259 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3a21d40c0dbaeb5f65db26044447d81b2d6ad6fc"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"189efae5269d1ccc776cf69e54f62ba378f36eaa"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk1-6.csv', 3663, 149, 28128, 29629))\nplot_play(game_df=game149, PlayID=3663, player1=28128, player2=29629 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"bc63e258d6847be353770afdc274d13a95a327f1"},"cell_type":"markdown","source":"# Regular Weekly Play Analysis from Week 7 - 12 "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"34dd4c4b16953ced2311acbbfbf6a1a61f9d4af0"},"cell_type":"code","source":"NGS_reg= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv')\nNGS_reg.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"c11e5c47b2cf8d99530cca42d9c327ee55d84784"},"cell_type":"code","source":"NGS_reg1= NGS_reg.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f9b12ca2530a0625edc3b7e5bf1890e99baaf7f4"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_reg1.x,y=NGS_reg1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"5703c3322155dc5243e836162a6739658063b485"},"cell_type":"markdown","source":"**Position analysis of play during 2016 Weekly season matches **"},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"faea2ee270df2ad7bc1a57b0c4e5d9709cdb4c84"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_reg, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"092d084eddde6c16134a91cefb379b55c35a953d"},"cell_type":"code","source":"game189 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv',GameKey=189)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"bc530f6b7642fdb00d70c241af8f6d56a64e73b0"},"cell_type":"code","source":"game218 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv',GameKey=218)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"d4cf1b0e0734b35ee53b5ec7cf8b0e05d61a50de"},"cell_type":"code","source":"game231 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv',GameKey=231)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"b404a11774a5d3319b0dba1afc13d999bc23d8fb"},"cell_type":"code","source":"game234 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv',GameKey=234)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e465ccc6dbe980eb4fc1965ac1f9070d7edc0f36"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"5bb17e209b96fd701fc86924e867da4bf4227ee0"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv', 3509, 189, 27595, 31950))\nplot_play(game_df=game189, PlayID=3509, player1=27595, player2=31950 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"5317fceba3b0ab95cd567de79c16011e8d1aea1c"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv', 3468, 218, 28987, 31950))\nplot_play(game_df=game218, PlayID=3468, player1=28987, player2=31950 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"c968d309efbf60ad0786045641a48666f4dd1321"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv', 1976, 231, 32214, 32807))\nplot_play(game_df=game231, PlayID=1976, player1=32214, player2=32807 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"699d8bdc8072394ebbb6299306f06b08471e6cde"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[3][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[3][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[3][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[3][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk7-12.csv', 3278, 234, 28620, 27860))\nplot_play(game_df=game234, PlayID=3278, player1=28620, player2=27860 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"511840a26abf8228c0971ed8eaf4675b2ae191d5"},"cell_type":"markdown","source":"# Regular Weekly Play Analysis from Week 13 - 17 "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"9ca07c2ae17a08e918862516da605f9fd9b8208f"},"cell_type":"code","source":"NGS_reg= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',low_memory=False)\nNGS_reg.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"df4496451e5944bbf34672d3a7a995f468a81714"},"cell_type":"code","source":"NGS_reg= NGS_reg.fillna(0)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"e67e3ad486032fba1150cb21bc49b7b8757e4559"},"cell_type":"code","source":"NGS_reg1= NGS_reg.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"c029bfe8e822e793dd7969c9dcb63f7dbf5a6e64"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_reg1.x,y=NGS_reg1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"4e4a41266193d22f35bc8bdb5a0bc08e3cd1d7d1"},"cell_type":"markdown","source":"**Position analysis of play during 2016 Weekly season matches **"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"f1b37bdb2a5433c82a2418a4d4cc07bd7e9cdd3a"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_reg, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"1260824fecaff539d1dbbb4965fa4b62a0fcd027"},"cell_type":"code","source":"game266 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',GameKey=266)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"701a9c991955a298993cf6aecd9cb00b325765af"},"cell_type":"code","source":"game274 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',GameKey=274)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"aa9648d7b518ea7048c24c3915cb0a10d731147f"},"cell_type":"code","source":"game280 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',GameKey=280)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"9f06d18f8bde7f0f58ae08b3c4237c373df91f3d"},"cell_type":"code","source":"game281 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',GameKey=281)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f57b559defce90613c60a4905f8e087dd78cd4d7"},"cell_type":"code","source":"game289 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',GameKey=289)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d2be2d4a46855b7d5d8ba1243db27f204aa071a2","_kg_hide-input":true},"cell_type":"code","source":"game296 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv',GameKey=296)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a64b12693f8558d9d53e52362e5fd338dd23bf0c"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"trusted":true,"_uuid":"55b04a8bf5686c75ebdfbbc87507134237e6cc13","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv', 2902, 266, 23564, 31844))\nplot_play(game_df=game266, PlayID=2902, player1=23564, player2=31844 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"ec2ba15c153b543b69d4fd90235b8f5e33422886"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv', 3609, 274, 23742, 31785))\nplot_play(game_df=game274, PlayID=3609, player1=23742, player2=31785 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"7b66beafb25ab29cf5c841634c3d322747b131ae"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv', 2918, 280, 32120, 32725))\nplot_play(game_df=game280, PlayID=2918, player1=32120, player2=32725 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"0d0e4a64a5a47128759b81c434d6d9bd2f89b108"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[3][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[3][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[3][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[3][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv', 1526, 281, 28987, 30789))\nplot_play(game_df=game281, PlayID=1526, player1=28987, player2=30789 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"a1b99e4bc31438be730e7b97b98d1732b39f237b"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[4][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[4][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[4][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[4][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv', 2341, 289, 32007, 32998))\nplot_play(game_df=game289, PlayID=2341, player1=32007, player2=32998 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"e5f76df0c3c37c12de621a16a73c1626216ea9ab"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[5][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[5][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[5][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[5][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2016-reg-wk13-17.csv', 2667, 296, 32783, 32810))\nplot_play(game_df=game296, PlayID=2667, player1=32783, player2=32810 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e5082bcac87ddd0180e81c2fc9a0abca79fb2dd4"},"cell_type":"markdown","source":"# Post Season Analysis of 2017 NFL Matches"},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"8921d7728706159eab83dadb7b5f64363cccd7ba"},"cell_type":"code","source":"NGS_post= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2017-post.csv')\nNGS_post.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"d480f4fa6fe262cfe63ec53cbdeb781f4fd6abbe"},"cell_type":"code","source":"NGS_post1= NGS_post.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"aa30c6c775af7fde945697dca1415b02110eb5a4"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_post1.x,y=NGS_post1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9ae088621833b6efc2ab4e5897c2ce8e25076222"},"cell_type":"markdown","source":"**Position analysis of play during 2017 Post season matches **"},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"6a1dd2810e1b314792fb077925d7297413cffe2b"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_post, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f05ebb8d4abce26eb2d5860124de9f3ed683a521"},"cell_type":"markdown","source":"# **No concussion incident happened during 2017 post season matches.**"},{"metadata":{"_uuid":"273211fef88b6af2574f9afc4fca8adac0082071"},"cell_type":"markdown","source":"# Pre Season Analysis of 2017 NFL Matches"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"eb7e7a0b6424e66c98d7715831a0530d9295e4ed"},"cell_type":"code","source":"NGS_pre= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv')\nNGS_pre.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"4dff297bcc9f54f7ae8e51740db189848de06f53"},"cell_type":"code","source":"NGS_pre1= NGS_pre.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"ba6ed8ccbfb384ff3a9aa8f04369705ed9983306"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_pre1.x,y=NGS_pre1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"50a9b3ff80c7c54e5efd3beef09bc7d947ff34ba"},"cell_type":"markdown","source":"**Position analysis of play during 2017 Pre season matches **"},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"50f505f7f82bd50f81287905388907bf18af998f"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_pre, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"c053e2ec914cc7e3e9472a3d9aa09bcaf8f3c8da"},"cell_type":"code","source":"game357 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv',GameKey=357)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"43ec4b2aee56565d56907495198c39b189ed828b"},"cell_type":"code","source":"game364 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv',GameKey=364)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"464704d74a5834f538063e8f57df09f46870bcaf","_kg_hide-input":true},"cell_type":"code","source":"game384 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv',GameKey=384)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7f3ac9859dd05062e76736cea9f0971d5c2a8cb2","_kg_hide-input":true},"cell_type":"code","source":"game392 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv',GameKey=392)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"fb1ef41aae054f81c3911c641a43d8316c8d4dbf"},"cell_type":"code","source":"game397 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv',GameKey=397)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"97da49787a16ca53b7eeada8e93092d492db5cb8"},"cell_type":"markdown","source":""},{"metadata":{"_uuid":"77c020ecf7c8ad3b26343b6c3fa716c0f2f6b5c7"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3cf99d3a1051b9e10a48b86f7bd83b63d589633d"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv', 3630, 357, 30171, 29384))\nplot_play(game_df=game357, PlayID=3630, player1=30171, player2=29384 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f476048ae3cee198f5ac04898453175e310d18b9"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv', 2764, 364, 32323, 31930))\nplot_play(game_df=game364, PlayID=2764, player1=32323, player2=31930 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"e001ca03225a56f930ccaf82ba873eb064da82e3"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv', 183, 384, 33813, 33841))\nplot_play(game_df=game384, PlayID=183, player1=33813, player2=33841 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"6aa52a35383aef99c780a6c0333e635ef13f2d09"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[3][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[3][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[3][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[3][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv', 1088, 392, 32615, 31999))\nplot_play(game_df=game392, PlayID=1088, player1=32615, player2=31999 )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"52227611e1224895e0221452418726547a8fde73","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[4][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[4][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[4][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[4][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-pre.csv', 1526, 397, 32894, 31763))\nplot_play(game_df=game397, PlayID=1526, player1=32894, player2=31763 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6d2037e7553a1e22f993566e4567c2baf486c10c"},"cell_type":"markdown","source":"# Regular Weekly Play Analysis from Week 1 - 6 "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"7815c806bf5800deb39ac9350d9e682c195457f3"},"cell_type":"code","source":"NGS_reg= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv')\nNGS_reg.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"b47fa60d8a7f4639baa52b60d8660afc4bd9d4e3"},"cell_type":"code","source":"NGS_reg1= NGS_reg.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"117768525e2a572e8d623b5fc8b669501af7c6ca"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_reg1.x,y=NGS_reg1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"e30d1d47c3acfde211e202be45c948181eb0100f"},"cell_type":"markdown","source":"**Position analysis of play during 2017 Weekly season matches **"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"a1098529e553d4111066cd9f1cf45594aff8a196"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_reg, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"67f490bb9dfe9d263dbf931a4e818786f9a588c2"},"cell_type":"code","source":"game399 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv',GameKey=399)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3bd34dc0b70bf306a06113d1edd95223eab189b7"},"cell_type":"code","source":"game414 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv',GameKey=414)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2c044c9292b73b6017eef3782b20f618b841f8ac","_kg_hide-input":true},"cell_type":"code","source":"game448 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv',GameKey=448)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"04103b0ebb9898f6265cb8f147861c2e83bb11e1","_kg_hide-input":true},"cell_type":"code","source":"game473 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv',GameKey=473)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"65b99bbc2b158c84b40168fe4bee8b5450f0d1bf"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f4f0a17da9102cfe85436cb73408d056a2aa79bf"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv', 3312, 399, 26035, 27442))\nplot_play(game_df=game399, PlayID=3312, player1=26035, player2=27442 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"cb85c78970936faeafd28f9a67d7555c95cb0592"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv', 1262, 414, 33941, 27442))\nplot_play(game_df=game414, PlayID=1262, player1=33941, player2=27442 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"13e3ad627cd323db28de3707bbb294cfb960ff6b"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv', 2792, 448, 33838, 31317))\nplot_play(game_df=game448, PlayID=2792, player1=33838, player2=31317 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"57cfa51e9bc0d5cb788122d57c0af23b8dfbdbf3"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[3][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[3][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[3][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[3][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk1-6.csv', 2072, 473, 29492, 33445))\nplot_play(game_df=game473, PlayID=2072, player1=29492, player2=33445 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"301dfccacd91e92889884b28878584953160a10a"},"cell_type":"markdown","source":"# Regular Weekly Play Analysis from Week 7 - 12 "},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"fcc81828ceea75a7c7a48f7db85bec8bdbe5484f"},"cell_type":"code","source":"NGS_reg= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv')\nNGS_reg.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"7997113cfe5f7045843fcd5bb96127107279d219"},"cell_type":"code","source":"NGS_reg1= NGS_reg.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"2f205f30ebbe0edcd229e519a78bad5bd0d08d2d"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_reg1.x,y=NGS_reg1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0af0aee86f1dddbe68af307c485b48327583d869"},"cell_type":"markdown","source":"**Position analysis of play during 2017 Weekly season matches **"},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"bd495c01e3efaed0a27410735ed741b7a4159da7"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_reg, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"389af9f89214501390658d3965e2feec2f26b49d"},"cell_type":"code","source":"game506 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv',GameKey=506)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"4debd2875bdb8fa90bb4a364754b91dd18fd2c31"},"cell_type":"code","source":"game553 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv',GameKey=553)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"55ec4d5572fa5f17592a515b154912989ed5e526","_kg_hide-input":true},"cell_type":"code","source":"game567 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv',GameKey=567)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"7718bb9c0c9f11c9732355c106c09e5e0f36ce73"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"trusted":true,"_uuid":"59ad56b2adfcef412cebd293e039fd26311c1b08","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv', 1988, 506, 27060, 30780))\nplot_play(game_df=game506, PlayID=1988, player1=27060, player2=30780 )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4d94f5d1a28f62ba65ce6f32abe0f857c469c634","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv', 1683, 553, 32820, 25503))\nplot_play(game_df=game553, PlayID=1683, player1=32820, player2=25503 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"a2d6b3036e7c01ca012b0f717ffe24b632e5a225"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk7-12.csv', 1407, 567, 32403, 32891))\nplot_play(game_df=game567, PlayID=1407, player1=32403, player2=32891 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8e1b5368102a65dc378f774790f0f16977958434"},"cell_type":"markdown","source":"# Regular Weekly Play Analysis from Week 13 - 17 "},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"19609e26aa099ba57117ec923b2228fc90df0659"},"cell_type":"code","source":"NGS_reg= pd.read_csv('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv')\nNGS_reg.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"e39c36e8a72ccb63be2fef7c8891c1200ccd93c7"},"cell_type":"code","source":"NGS_reg1= NGS_reg.truncate(before=1, after=1000)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f027962d927b1c4d84d839ca3c4e5dfa5a2c7b05"},"cell_type":"code","source":"trace1= go.Scatter(x=NGS_reg1.x,y=NGS_reg1.y)\n\nfig=go.Figure(data=[trace1],layout=layout)\npy.iplot(fig)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"398f595f4e06afa3e5927cb719ae6a7762dd2b6f"},"cell_type":"markdown","source":"**Position analysis of play during 2017 Weekly season matches **"},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"6678df28e6749b7586732d683b5f65c9d483b2a8"},"cell_type":"code","source":"video_review1 = pd.merge(video_review,NGS_reg, on=['Season_Year','GameKey','PlayID','GSISID'])\nvideo_review1= video_review1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ea1c930a9ed27d354eeab230857715a0d9f0b849","_kg_hide-input":true},"cell_type":"code","source":"game585 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv',GameKey=585)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"a9b6309ac0bc261119234979343987662536bd8e"},"cell_type":"code","source":"game601 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv',GameKey=601)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"df53567f9e4f25106627ee88f2c440fb43ef82d5"},"cell_type":"code","source":"game607 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv',GameKey=607)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e525de7585208d99d56a79c94ac3e8a5346e8b11","_kg_hide-input":true},"cell_type":"code","source":"game618 = load_game_and_ngs('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv',GameKey=618)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f58960766738b6e970347c252d167107818c3f47"},"cell_type":"markdown","source":"# **Players and their Partner's Movement during the play which caused concussion**"},{"metadata":{"trusted":true,"_uuid":"9b81efd96351c9bc31607a8bfd89bd62469c2e28","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[0][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[0][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[0][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[0][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv', 2208, 585, 33069, 29414))\nplot_play(game_df=game585, PlayID=2208, player1=33069, player2=29414 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"f6fc507898ca64b363b7281362780362a251d200"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[1][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[1][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[1][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[1][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv', 602, 601, 33260, 31697))\nplot_play(game_df=game601, PlayID=602, player1=33260, player2=31697 )","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"97f60e728c23b4c6906e67eaf732729d75b9b032"},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[2][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[2][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[2][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[2][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv', 978, 607, 29793, 32114))\nplot_play(game_df=game607, PlayID=978, player1=29793, player2=32114 )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c85aa383db719f2ba303177782e842163cf2bb04","_kg_hide-input":true},"cell_type":"code","source":"# Plot a single play, with two players\nprint('Primary Impact:',video_review1.iloc[3][\"Primary_Impact_Type\"]) \nprint('Primary Activity:',video_review1.iloc[3][\"Player_Activity_Derived\"] )\nprint('Partners Activity:',video_review1.iloc[3][\"Primary_Partner_Activity_Derived\"] )\nprint('Players from same team :',video_review1.iloc[3][\"Friendly_Fire\"] )\nprint(get_speed('../input/NFL-Punt-Analytics-Competition/NGS-2017-reg-wk13-17.csv', 2792, 618, 31950, 326))\nplot_play(game_df=game618, PlayID=2792, player1=31950, player2=32677 )","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"ecb6557a3dc1678527cfd26dae170cf86297b6e0"},"cell_type":"markdown","source":"# **Analysis**\n**Over all the 37 visual of concussion play and players movement we can conclude few important things -**\n\n**1- Most of these tackles were full speed tackle or scrimmages.**\n\n**2- Most of these tackles were made on the end line.**\n\n**3- Most of these tackles were made while running back.**\n\n**4- These tackles almost happened at the maximum mph which shows full speed tackle or blocking helmet to helmet/body will increase the concussion rate.**\n\n**5- A better helmet or better rule for tackling/blocking using helmets.**\n\n**6- Play continued on in many cases without the follow checkup on the injured/down player.**"},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"9534bed68971f2ef438331a194013656f34bc9bd"},"cell_type":"code","source":"play_info= pd.read_csv('../input/NFL-Punt-Analytics-Competition/play_information.csv')\nplay_info.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"4e42cbf9d8199e217c7276dc674f05cc7862a2ff"},"cell_type":"code","source":"play_info1 = pd.merge(video_review,play_info, on=['Season_Year','GameKey','PlayID'])\nplay_info1.sort_values('PlayID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dec18b5b041412301a04ea3cd44fd6f981b5f93c","_kg_hide-input":true},"cell_type":"code","source":"punt_count = play_info1['Quarter'].value_counts()\ntrace = go.Pie(labels=punt_count.index, values=punt_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Most concussion Quarter'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"fb00b4cb3e4fac5e71127bd3ee757b863d0dd55c"},"cell_type":"markdown","source":""},{"metadata":{"trusted":true,"_uuid":"6f4eadcaaa4fa2bea36109e4cb5a4b281619f4ef","_kg_hide-input":true},"cell_type":"code","source":"punt_count = play_info1['Poss_Team'].value_counts()\ntrace = go.Pie(labels=punt_count.index, values=punt_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Team percentage Punt play which lead to injury'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9ff9c47426477551f0c719aacc840acab99b4f20"},"cell_type":"markdown","source":""},{"metadata":{"trusted":true,"_uuid":"a24e633855edfee51680467e9b6db244f0c4aa4c","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"punt_data= pd.read_csv('../input/NFL-Punt-Analytics-Competition/player_punt_data.csv')\npunt_data.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"16ee9aa3ebdb32316ce6b9ed94c02cd387a5e0aa"},"cell_type":"code","source":"punt_data1 = pd.merge(video_review,punt_data, on=['GSISID'])\npunt_data1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3f94fb17e8272042c5a557f48d7a22bff679b0c5","_kg_hide-input":true},"cell_type":"code","source":"punt_count = punt_data1['Position'].value_counts()\ntrace = go.Pie(labels=punt_count.index, values=punt_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Concussion Position Percentage'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"b35725ef58d2c142569c69f1b344d66e5a2e294e"},"cell_type":"markdown","source":"**Tight End (TE) – This player is a hybrid between a receiver and an offensive lineman. Generally, he lines up next to the LT or RT or he can “split out” like a wide receiver. His duties include blocking for both the quarterback and the running backs, but he can also run into the field and catch passes. Tight ends can catch like a receiver, but has the strength and size to dominate on the line.**\n\n**Inside linebackers (ILB) are usually responsible for shadowing RBs, TEs and sometimes WRs; rushing the passer; and tackling ball carriers. Those who are linebackers are likely strong and fast.**\n\n**These two positions where concussion happened more than often and due to tackling and getting blocked in such positions they player got injured, these two position each share equal percentage of 15.5%.**"},{"metadata":{"_uuid":"6a4bbaaf6409fd2b35ea45313ab0c0aad6143113"},"cell_type":"markdown","source":"**In American football If the receiving team drops the ball or touches the ball beyond the line of scrimmage without catching it then it is considered a live ball and may be recovered by either team. If the receiving team never had full possession, it is considered to be a muffed punt rather than a fumble.**"},{"metadata":{"_uuid":"5b89b5f647f22e35d268328a993ef8a7c2618801"},"cell_type":"markdown","source":"![](http://images.performgroup.com/di/library/sporting_news/12/2e/tyler-matakevich-britton-colquitt-ftr-091017jpg_c0c6pnoga1ak1ovwx0mhut0dg.jpg?t=1824294750&w=960&quality=70)"},{"metadata":{"trusted":true,"_uuid":"d902fe52462800310b772182c72bb1e628d81fe1","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"player_role= pd.read_csv('../input/NFL-Punt-Analytics-Competition/play_player_role_data.csv')\nplayer_role.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-output":true,"_kg_hide-input":true,"trusted":true,"_uuid":"3ce259b0ef53846d0e9f1bf219b7120299eb05bb"},"cell_type":"code","source":"player_role1 = pd.merge(video_review,player_role, on=['Season_Year','GameKey','PlayID','GSISID'])\nplayer_role1.sort_values('GSISID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9406fec787b903d2f50f8ba1053abc31d6b2bb7d","_kg_hide-input":true},"cell_type":"code","source":"role_count = player_role1['Role'].value_counts()\ndata = [go.Bar(\n    x = role_count.index,\n    y = role_count.values,\n    marker = dict(color = random_colors(100))\n)]\nlayout = dict(\n         title= \"Role count leading to Injury\"\n)\nfig = dict( data=data, layout=layout )\niplot( fig, validate=False )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a322e73f7753102c4981ff949ca3fd861a1da5b6","_kg_hide-input":true},"cell_type":"code","source":"punt_count = player_role1['Role'].value_counts()\ntrace = go.Pie(labels=punt_count.index, values=punt_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Player role percentage'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"f2673c82cf2aa895bc3e5c7d4f903fdd6475fa0d"},"cell_type":"markdown","source":"**Punt Returners are responsible for catching kicked balls (either on kickoffs or punts) and running the ball back. These are usually among the fastest players on a team. Teams may use the same player for both positions or may have a separate returner for punts and for kickoffs. Returners typically also play wide receiver or cornerback. Due to the relatively high likelihood of injury during kick returns, most professional teams will not regularly use their very best WRs or CBs as returners.**"},{"metadata":{"trusted":true,"_uuid":"b5ee029c66a60e4432c6acc3eed38f7b9465ff2f","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"video_footage_control= pd.read_csv('../input/NFL-Punt-Analytics-Competition/video_footage-control.csv')\nvideo_footage_control.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"720cd98f329838dce0e032ce895395ae25aed7c6"},"cell_type":"code","source":"video_footage_control.rename(columns={'season': 'Season_Year', 'gamekey': 'GameKey', 'playid': 'PlayID'}, inplace=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"6d4d6093b77a568f57c87db7056746c90f6c034a"},"cell_type":"code","source":"player_role1 = pd.merge(video_review,video_footage_control, on=['GameKey','PlayID','Season_Year'])\nplayer_role1.sort_values('PlayID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"73fa53dc8a2d9b76699f9ead53ee3833ff12f660","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"video_footage_injury= pd.read_csv('../input/NFL-Punt-Analytics-Competition/video_footage-injury.csv')\nvideo_footage_injury.head()","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"3dca510bc8c84a6acf781bd622be77e71dee9e84"},"cell_type":"code","source":"video_footage_injury.rename(columns={'season': 'Season_Year', 'gamekey': 'GameKey', 'playid': 'PlayID'}, inplace=True)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"_kg_hide-output":true,"trusted":true,"_uuid":"2fbf0ff4125336265d723adeb52748b0490abd1a"},"cell_type":"code","source":"player_role1 = pd.merge(video_review,video_footage_injury, on=['GameKey','PlayID','Season_Year'])\nplayer_role1.sort_values('PlayID', ascending=False).drop_duplicates('GameKey').sort_index()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6733dbf903a528f429327da05714e852a985e07d","_kg_hide-input":true},"cell_type":"code","source":"punt_count = player_role1['Home_team'].value_counts()\ntrace = go.Pie(labels=punt_count.index, values=punt_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Home team injury involvement percentage'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e59c874175cc5b1eff8c96b892184608bf873195","_kg_hide-input":true},"cell_type":"code","source":"punt_count = player_role1['Visit_Team'].value_counts()\ntrace = go.Pie(labels=punt_count.index, values=punt_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Visit team injury involvement percentage'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"df4722abc088a729e5aeb8e05109eb125f761038","_kg_hide-input":true},"cell_type":"code","source":"trace0 = go.Scatter(\n    x=player_role1.Home_team,\n    y=player_role1.Player_Activity_Derived,\n    mode='markers',\n    marker=dict(\n        color=random_colors(50)\n\n    )\n)\nlayout = dict(\n            title='Home team players activity leading to concussion '\n)\nfig = go.Figure(data=[trace0], layout=layout)\npy.iplot(fig, filename='bubblechart-color')","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"e2b79fbdc691a1798d28574e8149530406608946"},"cell_type":"code","source":"trace0 = go.Scatter(\n    x=player_role1.Visit_Team,\n    y=player_role1.Player_Activity_Derived,\n    mode='markers',\n    marker=dict(\n        color=random_colors(50)\n\n    )\n)\nlayout = dict(\n            title='Away team players activity leading to concussion '\n)\nfig = go.Figure(data=[trace0], layout=layout)\npy.iplot(fig, filename='bubblechart-color')","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"4252a85415bdba52c272b0b8cf6235bb26ce0267"},"cell_type":"markdown","source":"# Major Foul Rules In NFL"},{"metadata":{"_uuid":"4671be73aa8f05aa2031e80d22df9398a1ed67c4"},"cell_type":"markdown","source":"> SECTION 14 - FOULS AND SPOTS OF ENFORCEMENT, VIOLATION\n> ARTICLE 1. TYPES OF FOULS\n> A Foul is any infraction of a playing rule for which a penalty is prescribed.\n> \n> A Live Ball Foul is a foul that occurs during the period after the snap until the ball is dead.\n> A Dead Ball Foul is a foul that occurs in the continuing action after a down ends, or a taunting foul that occurs at any time.\n> A Foul Between Downs is a foul that occurs after the end of the down and after any continuing action resulting from the down, but prior to the next snap or free kick.\n> A Multiple Foul is one of two or more fouls by the same team during the same down (14-1-3), including dead ball fouls.\n> A Double Foul is a foul by either team during the same down during which both teams commit at least one foul, including dead ball fouls.\n> ARTICLE 2. BASIC SPOT\n> The Basic Spot is a reference point for specific types of plays that is used to determine the Spot of Enforcement.\n> \n> ARTICLE 3. SPOTS OF ENFORCEMENT\n> The Spot of Enforcement is the spot at which a penalty is enforced. Six such spots are commonly used:\n> \n> The Previous Spot: The spot at which the ball was last put in play.\n> The Spot of the Foul: The spot at which a foul was committed or, by rule, is considered to have been committed.\n> The Spot of a Backward Pass or a Fumble: The spot at which the backward pass or fumble occurred during the down in which there was a foul.\n> The Dead Ball Spot: The spot at which the ball became dead.\n> The Succeeding Spot: The spot at which the ball will next be put in play (i.e., the spot of the ball after enforcement for a foul, or, if there has been no foul, the spot at which the ball became dead.)\n> The Spot of a Change of Possession: The spot at which possession is gained by or awarded to the opponent.\n> ARTICLE 4. VIOLATION\n> A violation is an infraction of a playing rule for which a penalty is not prescribed. A violation does not offset a foul.\n> \n> SECTION 15 - HANDLING THE BALL\n> Handing the ball is transferring player possession from one teammate to another without passing or kicking it.\n> \n> Except where permitted by rule, handing the ball forward to a teammate is illegal.\n> Loss of player possession by unsuccessful execution of attempted handing is a fumble charged to the player that last had possession. A muffed handoff (legal or illegal) is a fumble, and the ball remains alive.\n> A forward handoff occurs when the ball is handed (regardless of the direction of the movement of the ball) to a player who is in advance of a teammate from whose hands he takes or receives it.\n> SECTION 16 - HUDDLE\n> A Huddle is the action of two or more players in the field of play or in the end zone who, instead of assuming their normal position for the snap, free kick, or Fair Catch kick form a group for receiving instructions for the next play or for any other reason.\n> \n> SECTION 17 - IMPETUS\n> Impetus is the action of a player who carries the ball or provides the force (i.e., a pass, kick, snap, or fumble) that causes a ball in the field of play to touch or cross a goal line. If a Loose Ball touches or crosses a goal line, the impetus is attributed to the team whose player passed, kicked, snapped, or fumbled the ball, unless an opponent:\n> \n> muffs a ball that is at rest, or nearly at rest; or\n> bats a ball that has been kicked or fumbled; or\n> bats a backward pass after it has struck the ground; or\n> illegally kicks any ball (12-5-2).\n> Notes\n> \n> 1. The impetus is always attributed to the offense, unless the defense creates a new force that sends the ball behind its own goal line by muffing a ball which is at rest or nearly at rest, or by batting a loose ball on the ground or kicking any loose ball.\n> \n> 2. If a passive player is pushed or blocked into any kicked or fumbled ball or into a backward pass after it has struck the ground, causing the Loose Ball to touch a goal line or anything on or behind a goal line, the impetus is attributed to the pusher or blocker, provided that the pushed (blocked) player was not making an attempt to block an opponent.**"},{"metadata":{"trusted":true,"_uuid":"9ef2ca51d4cb86e08b06e7101d5d723452e93f05","_kg_hide-input":true,"_kg_hide-output":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"88dfb9956e73bd4a4c22e015e1bdff549403e5d3","_kg_hide-input":true},"cell_type":"code","source":"video_review= video_review.fillna(0)","execution_count":null,"outputs":[]},{"metadata":{"_kg_hide-input":true,"trusted":true,"_uuid":"618831af9b1c48fa2b4292631f1d6c42d214f2ea"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bd371e5105b4b7efbbd5e9aa5cddbb440710e81f","_kg_hide-input":true},"cell_type":"code","source":"video_review= video_review[['Player_Activity_Derived','Turnover_Related','Primary_Impact_Type','Primary_Partner_Activity_Derived','Friendly_Fire']]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bafaf3d6a07b3420ed9ef4ff62f403437da6a908","_kg_hide-input":true},"cell_type":"code","source":"s = pd.crosstab(video_review['Primary_Impact_Type'],\n                video_review['Friendly_Fire'] ,normalize='index').style.background_gradient(cmap='RdBu', low=.1, high=0).highlight_null('red')\ns","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3073e2f79ffb7d0e49dac776c6bce18e0c690ed8"},"cell_type":"markdown","source":"# Analysis -\n**1. Helmet to body contact in non friendly manner leads to 76% of injuries.**\n\n**2. Helmet to helmet contact in non friendly manner leads to 88% of injuries.**"},{"metadata":{"trusted":true,"_uuid":"70039177574d5f9e943d239edcbf203e720ed8ea","_kg_hide-input":true},"cell_type":"code","source":"s = pd.crosstab(video_review['Player_Activity_Derived'],\n                video_review['Primary_Partner_Activity_Derived'] ,normalize='index').style.background_gradient(cmap='RdBu', low=.1, high=0).highlight_null('red')\ns","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8263cb55724015909a29064eb1fcc5acafbfabfc"},"cell_type":"markdown","source":"# Analysis-\n\n**1. While player has blocked already the opponent and their primary partner still is trying to do the blocking its leads to 55% of the concussions.**\n.\n\n**2. While player is trying to tackle the opponent and their primary partner has already tackled it leads to 67% of the concussions.**"},{"metadata":{"trusted":true,"_uuid":"faf1d8e0d146fffb3fa74ce673b8993c2fc309a4","_kg_hide-input":true},"cell_type":"code","source":"video_review_count = video_review['Primary_Impact_Type'].value_counts()\ntrace = go.Pie(labels=video_review_count.index, values=video_review_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Most Impact Type'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"0c0a18dd68e7f2a5aef83ac8e31de309ce69f085"},"cell_type":"markdown","source":"# Analysis-\n**1.  Helmet to Body and Helmet to Helmet contact type leads to most concussion injuries. **"},{"metadata":{"trusted":true,"_uuid":"02f5e612d1ecef9edce20bafa4e4ccec47919931","_kg_hide-input":true},"cell_type":"code","source":"video_review_count = video_review['Player_Activity_Derived'].value_counts()\ntrace = go.Pie(labels=video_review_count.index, values=video_review_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Most activity percentage leading to concussion injury'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a663f71a4a52148f4633ca980ec8922069624782"},"cell_type":"markdown","source":"# Analysis-\n**1. Blocking and tackling each share fare amount of percentage leading to concussion injury.**"},{"metadata":{"trusted":true,"_uuid":"d8cc2e1c36a24f39f7a7528a9f0a4e7d0aee2e58","_kg_hide-input":true},"cell_type":"code","source":"serious_tackle= video_review.groupby(['Primary_Partner_Activity_Derived', 'Friendly_Fire'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"272e68778a69fa124513f6f957db7b8a2dcf6e8f","_kg_hide-input":true},"cell_type":"code","source":"partner_count = serious_tackle['Primary_Partner_Activity_Derived'].value_counts()\ntrace = go.Pie(labels=partner_count.index, values=partner_count.values, hole=0.6)\nlayout = go.Layout(\n    title='Percentage of partners serious play'\n)\nfig = go.Figure(data=[trace], layout=layout)\niplot(fig, filename=\"plotting-library\")","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9a8618c48ab333173edbdad9035b91d6dfd61b13"},"cell_type":"markdown","source":"# Anlaysis\n**1. Blocking event with primary partner also blocking with not in a friendly manner- 22.9 %**\n\n**2. Tackling event with primary partner also tackling  with not in a friendly manner- 22.9%**"},{"metadata":{"_uuid":"33538d314cb69b09ca7acd1db4cc3b8d06c344f4"},"cell_type":"markdown","source":"# NFL Injury Statistics (including Concussion, MCL, ACL)"},{"metadata":{"_uuid":"c548d7469487d40fa72f1d71b020afd21b3346c4"},"cell_type":"markdown","source":"![](https://www.playsmartplaysafe.com/wp-content/uploads/2018/01/injury-data-slide-1.jpg)"},{"metadata":{"_uuid":"eb1b3bbf09395038229961fda93547b4ad11a39e"},"cell_type":"markdown","source":"![](https://www.playsmartplaysafe.com/wp-content/uploads/2018/01/injury-data-slide-2.jpg)"},{"metadata":{"_uuid":"d5c3525c27ecaf41a0c490fa94511a13061af6f6"},"cell_type":"markdown","source":"![](https://www.playsmartplaysafe.com/wp-content/uploads/2018/01/injury-data-slide-3.jpg)"},{"metadata":{"_uuid":"8cdb2be59a9a4ca21724472398b34827dc885a2f"},"cell_type":"markdown","source":""},{"metadata":{"_uuid":"f1d4e6bd8c60de7c7322d39a4f814159df8627ea"},"cell_type":"markdown","source":"![](https://www.playsmartplaysafe.com/wp-content/uploads/2018/01/injury-data-slide-4.jpg)"},{"metadata":{"_uuid":"33d4cbb3b8e4a2d60cfba5498813d2f63ff472e4"},"cell_type":"markdown","source":"# NIH Report on Concussion"},{"metadata":{"_uuid":"a12248d7b72d8d244612a7e93e3cec9584e0ac9b"},"cell_type":"markdown","source":"**A concussion is a type of brain injury. It involves a short loss of normal brain function. It happens when a hit to the head or body causes your head and brain to move rapidly back and forth. This sudden movement can cause the brain to bounce around or twist in the skull, creating chemical changes in your brain. Sometimes it can also stretch and damage your brain cells.**\n\n**Sometimes people call a concussion a \"mild\" brain injury. It is important to understand that while concussions may not be life-threatening, they can still be serious.**\n\n**Concussions are a common type of sports injury. Other causes of concussions include blows to the head, bumping your head when you fall, being violently shaken, and car accidents.**\n\n**Symptoms of a concussion may not start right away; they may start days or weeks after the injury. Symptoms may include a headache or neck pain. You may also have nausea, ringing in your ears, dizziness, or tiredness. You may feel dazed or not your normal self for several days or weeks after the injury. Consult your health care professional if any of your symptoms get worse, or if you have more serious symptoms such as**\n\n**Convulsions or seizures\nDrowsiness or inability to wake up\nA headache that gets worse and does not go away\nWeakness, numbness, or decreased coordination\nRepeated vomiting or nausea\nConfusion\nSlurred speech\nLoss of consciousness\nTo diagnose a concussion, your health care provider will do a physical exam and will ask about your injury. You will most likely have a neurological exam, which checks your vision, balance, coordination, and reflexes. Your health care provider may also evaluate your memory and thinking. In some cases, you may also have a scan of the brain, such as a CT scan or an MRI. A scan can check for bleeding or inflammation in the brain, as well as skull fractures.**\n\n**Most people recover fully after a concussion, but it can take some time. Rest is very important after a concussion because it helps the brain to heal. In the very beginning, you may need to limit physical activities or activities that involve a lot of concentration, such as studying, working on the computer, or playing video games. Doing these may cause concussion symptoms (such as headache or tiredness) to come back or get worse. Then when your health care provider says that it is ok, you can start to return to your normal activities slowly.**"},{"metadata":{"_uuid":"0c343e19d8df9e1b77ecb160995c810b281e8c34"},"cell_type":"markdown","source":"![](https://c.o0bg.com/rf/image_1200w/Boston/2011-2020/2017/12/29/BostonGlobe.com/Sports/Images/df718101b1e04231b54ac3d654e9c5a0-df718101b1e04231b54ac3d654e9c5a0-0.jpg?uuid=uQuK7OzeEeerbgMQBVbbXg)"},{"metadata":{"_uuid":"14f2db7f80ae4dffff925ff0c0cc6597b962cac4"},"cell_type":"markdown","source":"**Concussion Protocol On Tom Savage as it should be mandatory for every Non-Friendly Blocking or Non Friendly Tackle**"},{"metadata":{"_uuid":"2bef1133f790c55e5375f17a0634a3336eaa0cf5"},"cell_type":"markdown","source":"**Prevention Tips**\t\n\n**Teach athletes proper techniques and ways to avoid hits to the head.**\n\n**Limit the amount of contact during practices. This may include**\n\n**No full speed head-on blocking or tackling drills in which the players line up more than 3 yards apart.**\n\n**Limiting the amount of practice time that includes scrimmages or full-speed drills.**\n\n**The American Academy of Pediatrics recommends:**\n\n**Expanding the availability of non-contact football programs.**\n\n**Having skilled athletic trainers available at games and practices.**\n\n**Keep a close eye on athletes during running plays, especially an athlete in the running back position.**\n\n**Enforce the rules of the sport for fair play, safety, and sportsmanship.**\n\n**Ensure athletes avoid unsafe actions such as:**\n\n**Hitting another athlete in the head;**\n\n**Using their helmet to contact another athlete (helmet-to-helmet or helmet-to-body contact);**\n\n**Making illegal contacts, tackling, or colliding with an unprotected opponent; and/or\nTrying to injure or put another athlete at risk for injury.**\n\n**Make sure athletes always wear a helmet that fits well and is in good condition.**\n\n**Work with the game or event administrator to remove tripping hazards and ensure equipment, such as goalposts, have padding that is in good condition.**\n\n**Why This Is Important**\n\n**Almost half (49%) of concussions in high school football happen during running plays.**\n\n**Tackling is responsible for almost two-thirds (63%) of concussions in high school football.**\n\n**Linebackers sustain over half (59%) of all concussions among high school football defensive players.**\n\n**Running backs sustain 46% of concussions among high school football offensive players.**"},{"metadata":{"_uuid":"13aa1fcc67bcc8ea88e5a3259b87978e5ee98d60","_kg_hide-input":true,"trusted":true},"cell_type":"markdown","source":"# Suggested Changes\n\n1. **As part of the new rule, which is considered unneccessary roughness, players will receive a 15-yard penalty and could possibly be ejected. The previous rule limited the penalty to contact to the crown of the helmet.The new rule officially reads, Lowering the head to initiate contact with the helmet is a foul. It is intended to remove unnecessary use of the helmet. The hits do not have to come to the head or neck but anywhere on the body. Players cannot use their helmets to butt, spear or ram an opponent.**\n\n**Plays subject to ejection include when a player has an unobstructed path to his opponent or contact was clearly avoidable, but the player chose to lower his head and use his helmet.**\n\n**Correction- There should be a speed parameter included to the rule, as in my analysis most of these players were travelling more than their avg miles/hr. If the player is lowering his helmet and moving more than avg miles/hr decided by NFL then he should be ejected from the game with 15 yards penalty and no ejection shall be committed if player lowers his helmet under stationary motion unless the player is taking down the moving player using his helmet.**\n\n2.**Protection of Punt Returners-\nIt is most often the Punt returners which face concussion during the tackle or by being blocked by imposing fair catch rule on them(5 yard award) or use canadian football rules which is The kicker and any players behind him at the time of the kick are considered onside; any other players on the kicking team are considered offside. A player who is onside may recover the kicked ball, while a player who is offside may not be the first to touch the kicked ball and is required to remain at least 5 yards from an opposing player attempting to catch the ball. Violations of these restrictions on an offside player are called no yards infractions, with various penalties associated with them. Better helmet for Punt Returners, punt left guard or punt right guard, or more protection for PR by giving him extra man in front of him in lineup formation rather than just PR only by himself.**\n\n3. **Blindsided block or Moving backwards block/tackle-**\n\n**Almost 30% of these concussion happened due to blindsided block or while those PLG/PLG were trying to catch the ball while moving backwards this cause some serious head blow to catchers if they got tackled while moving backwards.**\n\n**Another thing to mention that bad landing happened due to lack of vision to upcoming tackles, which caused them injury leading to concussion.**\n\n**Rule- A player who receives a “blindside” block when the path of the offensive blocker is toward or parallel to his own end line is a defensenless player.**\n\n**Correction- The blocking/tackling player should be in the eye range(180 degrees) of the player getting tackled regardless of it's position or direction.**\n\n**Rule- A receiver attempting to catch a pass who has not had time to clearly become a runner. If the player is capable of avoiding or warding off the impending contact of an opponent, he is no longer a defenseless player.**\n\n**Correction- There should not be any tackle on wing players who's moving towards his own end line or running backwards regardless of the player is capable of avoiding or warding off the impending contact of an opponent.**\n\n"},{"metadata":{"_uuid":"d4c6a16d66b5d675c40ef2b2229120435b44c70d"},"cell_type":"markdown","source":"# Upvote if you liked as i'll update more"}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}