{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"%%javascript\nIPython.OutputArea.prototype._should_scroll = function(lines) {\n    return false;\n}","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# NFL lower leg injuries: analysis"},{"metadata":{},"cell_type":"markdown","source":"**Disclaimer**\n\n\n*I have followed closely both college and professional football for over two decades. However I am a political scientist, journalist and published author, not a seasoned coder or data analyst. My knowledge of for example Python is pretty much nonexistent. To add its own spice in the stew is that fact that this is the very first time I am using Jupyter Notebook.*\n\n*For this analysis I first used an external SQL editor to polish up the datasets provided as well as create more readable dataframes. According to challenge outline the analysis conclusions must be returned in a slideshow format, so this notebook also includes text and other content meant for the slides.*"},{"metadata":{},"cell_type":"markdown","source":"**TABLE OF CONTENTS**\n1. Data <br>\n2. Research subject <br>\n2.1 *Player injury history* <br>\n2.2 *Surface*<br>\n2.3 *Shoes and cleats* <br>\n3. Analysis <br>\n3.1 *Linebacker* <br>\n3.2 *Wide receiver* <br>\n3.3 *Defensive back* <br>\n3.4 *Cornerback* <br>\n3.5 *Defensive linemen* <br>\n3.6 *Offensive linemen* <br>\n3.7 *Running back* <br>\n4. Conclusions <br>\n5. Afterword: lesson from NHA"},{"metadata":{},"cell_type":"markdown","source":"### 1. Data\n"},{"metadata":{},"cell_type":"markdown","source":"To begin with, I used SQL to join all the relevant data included in the InjuryRecord and PlayList tables to one table in the following manner:"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\ndf=pd.read_csv('../input/InjuredPlayers.csv')\ndf.head(6)\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The new table InjuredPlayers consists of 105 rows, but there are some factors that should be addressed more closely. First, only 77 of the 105 injury logs include the relevant data on Position and PositionGroup. Second, I noticed the following:"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/InjuredTwice.csv')\ndf.head(10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As one can see, **five pairs of entries share the same PlayerKey**. In one case (PlayerKey 47307) both PlayerKey, GameID as well as the PlayKey are the same, meaning the same injury has been fitted into two BodyPart subcategories. Thus one incident in a game has created two separate registry entries in the provided dataset. "},{"metadata":{},"cell_type":"markdown","source":"From viewpoint of statistics **105 (with 77 cases including roster positions) cases is arguably an insufficient sample to draw any correlation or deeper conclusions on football injuries and their possibile causes**. 57 of 105 provided lower leg injury cases (further LLI) took place on synthetic surface compared to 48 injuries on natural surface. As only some third of all NFL stadiums have synthetic surface, the role of synthetic surface in LLI  could be considered of significance at least as a working hypothesis for further analysis. However the provided dataset is not large enough to either confirm or refute this hypothesis. Also, **for future analyses such motion track data as 'team ID' and 'ball trajectory' would prove to be useful**.\n\n\n\n"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\ndf=pd.read_csv('../input/InjuredPlayers.csv')\n\nsns.set(rc={'figure.figsize':(9.7,8.27)})\nsns.set(font='sans-serif')\n\nplot = sns.countplot(x = 'Surface',\n              data = df,\n              order = df['Surface'].value_counts().index)\n\nplot.axes.set_title('Total count of injuries divided by surface',fontsize=24)\nplot.set_xlabel(\"Surface\",fontsize=18)\nplot.set_ylabel(\"Total count of injuries\",fontsize=18)\nplot.tick_params(labelsize=14)\n\nplt.show()\n\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Of the 105 LLI cases provided for analysis, **knee and ankle injuries were clearly the two major categories**. As for surface, knee injuries are split evenly between natural and synthetic surface, with 24 cases on both surfaces. According to data provided, ankle injuries took place more often on synthetic surface, with 25 ankle injuries on synthetic surface compared to 17 that were recorded on natural surface. As for other LLI cases in the data, 6 out of 7 cases of toe injuries were recorded on synthetic surface, whereas 5 out 7 cases of foot injuries were recorded on natural surface.\n"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(16.7,8.27)})\nsns.set(font='sans-serif')\n\ndf=pd.read_csv('../input/InjuredPlayers.csv', usecols = ['BodyPart', 'Surface'])\n\nplot = sns.countplot(x = 'BodyPart',\n              data = df,\n              hue = 'Surface',\n              order = df['BodyPart'].value_counts().index)\n\nplot.axes.set_title('FIGURE 1: total count of injuries divided by surface and body part',fontsize=24)\nplot.set_xlabel(\"Surface\",fontsize=18)\nplot.set_ylabel(\"Total count of injuries\",fontsize=18)\nplot.tick_params(labelsize=14)\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As the graph below shows, the dataset mainly includes injures from linebackers, wide receivers and safeties. There are no significant differences between roster position when surface is concerned. Then again, only about a third of all stadiums have synthetic surface. From this viewpoint, **injuries on artificial surfaces are overrepresented especially in the case of cornerbacks**."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(20.7,11.27)})\nsns.set(font='sans-serif')\n\ndf=pd.read_csv('../input/InjuredPlayers.csv', usecols = ['RosterPosition', 'Surface'])\n\nplot = sns.countplot(x = 'RosterPosition',\n              data = df,\n              hue = 'Surface',\n              order = df['RosterPosition'].value_counts().index)\n\nplot.axes.set_title('FIGURE 2: total count of injuries divided by surface and roster position',fontsize=24)\nplot.set_xlabel(\"Roster Position\",fontsize=18)\nplot.set_ylabel(\"Total count of injuries\",fontsize=18)\nplot.tick_params(labelsize=14)\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The included challenge outline does not provide clear criteria on how the 105 injury cases were selected. Moreover, the outline suggests that when the dataset in question is concerned, NFL would mainly be interested in the role of synthetic surface in non-contact lower leg injuries. However there are recurring mentions in the provided play event data that among the 105 injury cases included in the dataset are injuries with contact in play. For example of this, see chapter 3.1.\n\n"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/LineRoute.csv')\ndf.head(5)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The player in question (PlayerKey: 42600) is one of the linebackers included in the injured players dataset. The play in question is the player's very first play of the whole game: a punt return (PlayType = Kickoff). As the PlayKey column shows, this particular play was the only play the linebacker -  as part of special teams - took part of. This means the data is pristine concerning this analysis, because it can be assumed that the linebacker in question was injured in this very play.\n\nA simple scatterplot with player speed (yards per second) as the dot size and hue indicator returns the following graphic: "},{"metadata":{"scrolled":false,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\ndata = '../input/LineRoute.csv'\ndf = pd.read_csv(data, index_col=0)\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 3: PlayerKey 42600, kickoff return, PlayKey 42600-3-1',fontsize=24)\nplot.set_xlabel(\"Yards (x)\",fontsize=18)\nplot.set_ylabel(\"Yards (y)\",fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=2, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed yd/s')\n\nplt.annotate('play started', size = 14, xy=(44,33), xytext=(44,35), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('touchback', size = 14, xy=(83.6,40), xytext=(80,37.5), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As the kickoff took place, the linebacker took off from the right side (x = 44, y = 33). The kickoff resulted as touchback (x = 85, y = 40), causing the linebacker quickly decrease his speed. As the closer tracking plot below shows, the player ended up staying on the ground for a while after the play. This would suggest that the linebacker injured himself during the top-speed run before touchback. \n\n"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/LineRouteTeam.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 4: PlayerKey 42600, kickoff return, PlayKey 42600-3-1',fontsize=24)\nplot.set_xlabel(\"Yards (x)\",fontsize=18)\nplot.set_ylabel(\"Yards (y)\",fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=2, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed yd/s')\n\nplt.annotate('touchback', size = 14, xy=(83.9,40.1), xytext=(82,41), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The tracking data used in the plot graph was taken from the third csv datasheet provided by NFL Next Gen Stats (PlayerTrackData). The file in question includes a plethora of data on player movement in games. As the image below shows, first experiments of player tracking in NFL started six years ago. The current Next Gen Stats player tracking system was launched last summer (image: NFL Football Operations):   "},{"metadata":{},"cell_type":"markdown","source":"<img src= \"https://nflops.blob.core.windows.net/cachenflops-lb/3/e/d/7/6/d/3ed76de18f91f7fcf4cff0a0c1cd475c2df8c6ff.png\" width = 100%/> "},{"metadata":{},"cell_type":"markdown","source":"The tracking process is made possible by all coin-sized radio-frequency identification (RFID) chips. In games RFID tags are embedded on every player, official, game ball, pylon and first down chain (image: Zebra Sports):"},{"metadata":{},"cell_type":"markdown","source":"<img src= \"https://i2.cdn.turner.com/money/dam/assets/160909075115-zebra-technologies-coin-780x439.jpg\" width = 50%/> "},{"metadata":{},"cell_type":"markdown","source":"In the 2019 season, each NFL stadium has between 20 to 30 ultra-wide band receivers throughout the stadium for capturing the movement data. Altogether, an estimated 250 devices are in a venue for any given game. To ensure the whole setup works, each week the official player tracking representatives at every stadium confirm that all tracking systems are functioning properly.\n\nThe tracking system captures player data like location, speed, distance traveled as well as acceleration at a rate of 10 times per second. All charts and individual movements are measures within inches. After collecting the raw data, everything is provided to all 32 clubs, giving each team the option for developing their own custom analytics and statistics.\n"},{"metadata":{},"cell_type":"markdown","source":"## 2. Research subject"},{"metadata":{},"cell_type":"markdown","source":"### 2.1 Player injury history"},{"metadata":{},"cell_type":"markdown","source":"The National Football League (NFL) consists of 32 teams, each having 53-player active rosters. That makes 1696 players in total. According to the official NFL statistics, the total number of all reported injuries per season is in average about 1900 per one season. Thus **if a player is a week 1 starter in September in NFL, the odds of that very player getting injured during the season is - hypothetically - more than one hundred percent**.\n\n"},{"metadata":{},"cell_type":"markdown","source":"**Injuries in the NFL don’t however necessarily originate from playing professional football**. Most NFL team members have already been part of the game over a decade before turning professional. Although surfaces used in high school as well as college football lie outside of the scope of this analysis, as a working hypothesis it will be assumed that also these surfaces can both cause and aggravate lower leg injuries. As a result, players may already have a significant injury history before they have taken a single snap as professionals.\nWe also know from individual players’ injury history that LLI are often ‘nagging’ i.e. recurring by nature. As I write this in December, the news about Odell Beckham Jr's sports hernia broke, revealing that he has played with the injury ever since the season started. If Beckam is to leave a game with an injury in one of three remaining regular season games, the specific play shown in data would leave out the fact of him battling through the same injury for three months."},{"metadata":{},"cell_type":"markdown","source":"No player embodies this dilemma better than the Washington Redskins running back **Derrius Guice**. The 22-year-old Guice was a second round pick in 2018 NFL draft, and he was supposed to be a starter in the upcoming season. However Guice suffered a knee injury (torn ACL) during a preseason game in August 2018, and the injury ended up wiping out his whole first season. In June 2019, Guice tweaked his hamstring while rehabbing from the torn ACL. Guice finally made his debut in NFL with the Redskins in Week 1 against the Philadelphia Eagles. In the game. however Guice had to leave the game with a suspected knee injury."},{"metadata":{},"cell_type":"markdown","source":"It was later revealed that Guice had suffered a torn meniscus in his first game, requiring surgery, with him being placed on injured reserve on September 13th. Guice was reactivated off the injured reserve on November 7th. and four days later he took the field against the New York Jets in a week 11 matchup. Only two games later, in week 13, Derrius Guice again left the field mid-game, and he was diagnosed with a season-ending knee injury (MCL sprain) on December 10th 2019, leaving his whole career in question. Because of all this, **since the beginning of his professional NFL career Derrius Guice has appeared only in five games (one start) in two years and contributed 245 yards and two touchdowns on 42 carries**. Because of the nature of his injuries, it is however possible that he may have ended up as part of the dataset provided for this challenge. If that is indeed the case, it is good to know that a lot was going on before that one row of data was added in the player data. Also, drawing too deep conclusions based on that one row of data only would be somewhat misleading."},{"metadata":{},"cell_type":"markdown","source":"As the unfortunate case of Derrius Guice shows, **sometimes players either suffer from injuries first occurred already on high school or college level, or these injuries have first emerged in practice situations outside the actual games**. As for Guice, he is currently on team injured reserve despite barely showing up in actual NFL games. This 'wear and tear' affects all NFL players, whether we are talking about one game, a full season or even a whole career. Also, because of the tight schedule, during the season key NFL players often 'manage the pain' and play with a sustained injury in important games if they possibly can. Therefore **linking an injury to a specific spatio-temporal event in a dataset does not necessarily tell the whole truth about the incident**."},{"metadata":{},"cell_type":"markdown","source":"### 2.2 Surface"},{"metadata":{},"cell_type":"markdown","source":"Increasing the use of synthetic surface at football arenas is the current trend in the NFL. Instead of being venues for football only, the new stadiums are designed to be multi-use arenas, as live entertainment hubs, to increase venue use and thus the revenue the location can create.\n\nFor example, the new Allegiant Stadium in Las Vegas will be the new home of not only the Las Vegas Raiders but also the UNLV Rebels college football team. In addition to football, the stadium will host a great variety of other events such as live concerts. This means the arena surface has to be interchangeable - no fixed surface would survive under such heavy use.\n\nAs the image below showws, in football a synthetic surface consists of artificial fibres on top of rubber granules (image: Wikipedia Creative Commons):"},{"metadata":{},"cell_type":"markdown","source":"<img src= \"https://upload.wikimedia.org/wikipedia/commons/d/d8/Modernartificialgrass2.svg\" width = 75%/> "},{"metadata":{},"cell_type":"markdown","source":"Since this leaves plenty of wiggle room for teams to implement the basic concept, **it is safe to say that no two synthetic surfaces are exactly the same**. One possible factor affecting LLI cases is the ‘wear and tear’ of a particular surface. On natural surface this can be easily observed, but on synthetic surface the wear effect is often harder to spot. Therefore, as a working hypothesis, it is assumed that all synthetic surfaces consist of areas in relatively worse condition than the rest of the field, but that players cannot necessarily locate these areas easily mid-game on the field compared to natural grass surface. "},{"metadata":{},"cell_type":"markdown","source":"The ‘damp factor’ i.e. air and ground humidity could be of significance in LLI cases concerning the actual structure and building materials of synthetic surface. Since the dataset provided for this analysis does not enable a deeper analysis on air and surface humidity in individual games, this issue will be left as a possible subject for future analyses.\n\n**It would be useful to study lower leg injuries compared with other types of injury when synthetic surface is concerned**. For example, if synthetic surface were a factor also in shoulder injuries and concussions, then analysing only LLI cases would be just one part of a larger issue. As previously mentioned, from statistical viewpoint a random selection of 105 LLI cases is arguably insufficient to draw any well-founded conclusions on the subject matter."},{"metadata":{},"cell_type":"markdown","source":"There are also factors such as for example the altitude at the Mile High stadium in Denver that necessarily affects the premises of how a particular game turns out. Similarly, if a team has to take a cross-country flight before the game, this creates extra challenges for conditioning to loosen up the limbs and muscles to prevent injuries. Since these factors lie outside of the provided dataset, they will be left as questions for possible future studies."},{"metadata":{},"cell_type":"markdown","source":"### 2.3 Shoes and cleats"},{"metadata":{},"cell_type":"markdown","source":"The official NFL rules concerning football shoes mainly concentrate on the appearance by making sure that the official league logo on shoes are visible. In fact NFL rules would allow players to wear for example basketball shoes, if they are made by the official shoe sponsor of the league.\n"},{"metadata":{},"cell_type":"markdown","source":"However NFL does have tighter restrictions for cleats, which are the spikes attached to the bottom of the shoe. According to official rules, shoe cleats must be not be \"made of aluminum or other material that may chip, fracture or develop a cutting edge\". "},{"metadata":{},"cell_type":"markdown","source":"**The cleats players use - with fixed or switchable spikes on the bottom of the shoe - often vary depending on surface and weather conditions**. As cleats are in constant contact with the surface during the game, this is a variable with significant hypothetic relevance concerning lower leg injuries. However cleats used by players are beyond the data available and will thus be sidelined in this analysis."},{"metadata":{},"cell_type":"markdown","source":"## 3. Analysis"},{"metadata":{},"cell_type":"markdown","source":"Modern football is allegedly a fast-paced game based on deep passes. On the other hand a run/pass offense (RPO) has thrived lately with quarterbacks like Patrick Mahomes and Lamar Jackson. In the current Baltimore Ravens roster their quarterback Lamar Jackson is allegedly one of the fastest players, which gives a whole new dimension to playcalling.\n\nTaking advantage of RPO means that defense won't know whether to expect a run or a pass play. On the other hand RPO requires quick adaptation from both offense and defense.\n\nIn this chapter, the provided injury dataset will be analysed from the viewpoint of position groups, but in a way this is an obsolete way of observing football in 2019. **Many teams these days have 'flex players' capable of lining up in different positions: some of them occasionally even switch from offense to defense or vice versa**. These kind of players are valuable and sought after, but on the flipside increasing the number snaps these players take in a game inevitably increases also their injury probability.\n\n\nThere are also factors in football even the most extensive data cannot measure. Is the head coach on hot seat or maybe a rookie? Is the team record 1-9 after ten games? Is the locker room united? Maybe the top running back's contract was just extended but the quarterback didn't get a new deal? In NFL success is often measured using stats and data, but if it were possible to create success merely by browsing through extensive statistics and motion sensor data, the sensor connected to Lombardi Trophy would not have to be traced just to Boston so often come mid-February."},{"metadata":{},"cell_type":"markdown","source":"### 3.1 Linebacker"},{"metadata":{},"cell_type":"markdown","source":"As part of the secondary, spread behind defensive line, linebackers form an integral part of defense playbook in modern football. Whether the offense chooses a run or a pass play, linebackers must position themselves correctly, and everything must happen in a blink of an eye especially if the offense is type RPO. Offensive linebacker are also responsible for blitzing the quarterback as well as covering passes in the edge areas near the sideline.\n\nHowever, as mentioned before, drawing any widespread conclusions from such a small and seemingly random sample of injury data would not serve the purpose of analysing player injuries in a constructive manner. In a nutshell, the linebacker data includes the following basic information:\n\n"},{"metadata":{},"cell_type":"markdown","source":"- **21 recorded injuries**\n- **position OLB (10), MLB (4), ILB (3)**\n- **main play types for injuries: punt (6), rush (8)**\n- **11 injuries took place on natural surface, 10 on synthetic**\n- **an injured player participated in 10 or less plays in 7/21 cases**\n- **the average running count of plays in a game before injury: 24.8**\n- **14/21 injury cases were recorded in outdoor games (0/14 outdoor games had rain)**\n- **11 injuries were knee injuries, 10 were ankle injuries**\n- **5 injury cases lead to missing 42 or more days**\n- **8 injury cases lead missing 28 or more days**"},{"metadata":{},"cell_type":"markdown","source":"After joined with the player tracking data, the following table, including only linebacker as PositionGroup, was created. All linebackers included in the dataset were listed as injured during play:"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/LineJoinC.csv')\ndf.head(6)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The simple bar graphic below compares BodyPart column to player speed (yards per second) in linebacker injury cases included in the dataset. As one can see, when the player median speed increases, the likelihood for him to suffer a knee injury instead of an ankle injury also increases:"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/LineJoinC.csv', usecols = ['BodyPart', 's'])\n\nplot = sns.barplot(\n    data=df ,\n    x='BodyPart' ,\n    y='s',\n    estimator= np.median\n )\n\nplot.axes.set_title('FIGURE 5: Linebacker injuries: body part and median speed (yd/s)',fontsize=24)\nplot.set_xlabel(\"Body Part\",fontsize=18)\nplot.set_ylabel(\"Median Speed (yd/s)\",fontsize=18)\nplot.tick_params(labelsize=14)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When PlayType is added to the picture, the top-speed kickoff plays show up as a significant factor in linebacker knee injuries, punt plays being the good second:"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/LineJoinC.csv', usecols = ['BodyPart', 'PlayType', 's'])\n\nplot = sns.barplot(\n    data=df ,\n    x='PlayType' ,\n    y='s',\n    estimator= np.median,\n    hue = 'BodyPart'\n )\n\nplot.axes.set_title('FIGURE 6: Linebackers: PlayType, BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel(\"Play Type\",fontsize=18)\nplot.set_ylabel(\"Median Speed (yd/s)\",fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=2, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As noted earlier, one of the linebackers was listed twice in the InjuredPlayers dataset. Below is a scatterplot presentation of first of the two entries (the one player allegedly injured his ankle and tried later to return to the game). In the pass play, there was first a huddle (x = 78, y = 23). After the snap took place (x = 75, y = 29) and quarterback passed the ball (x = 72, y = 35), the pass was caught (x = 67, y = 36) after which the event list in the dataset lists first_contact (x = 66, y = 36) followed by tackle shortly afterwards. **The provided dataset only lists events such as 'contact' or 'tackle' to have taken place in a play. This does not mean that the player included in the dataset was in any way the one engaging in contact or tackle**."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(12.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/LineRouteB.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 7: PlayerKey 43540, pass play, PlayKey 43540-2',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=3, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\nplt.annotate('pre-snap huddle', size = 14, xy=(75,24.3), xytext=(75,23), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('snap', size = 14, xy=(75,29.7), xytext=(73,29.7), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('quarterback pass', size = 14, xy=(72.3,35.2), xytext=(74,36), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('pass catch', size = 14, xy=(67.3,36), xytext=(68,35), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('contact', size = 14, xy=(66.5,36), xytext=(64,36), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"\nWhat we can see from the dataset is that in these days linebackers are used in multiple ways in defense and special teams. This means that they are often required to perform short-burst plays in full speed, with the possibility of tackle or other player contact."},{"metadata":{},"cell_type":"markdown","source":"### 3.2 Wide Receiver"},{"metadata":{},"cell_type":"markdown","source":"In the dataset provided, there was a total of 16 plays where a wide receiver suffered an injury. In brief, the wide receiver dataset looks like this:"},{"metadata":{},"cell_type":"markdown","source":"\n- **16 recorded injuries**\n- **main play types for injuries: pass (8), kickoff (4)** \n- **7/16 injuries took place on natural surface, 9/16 on synthetic**\n- **an injured player participated in 10 or less plays in 4/16 cases**\n- **the average running count of plays before injury: 22.8**\n- **9/16 games were outdoor games (4/9 had rain)**\n- **7 injuries were knee injuries, 8 ankle injuries, 1 foot injury**\n- **4 injuries lead to missing 42 or more days**\n- **5 injuries lead to missing 28 or more days**\n- **10 injuries lead to missing 7 or more days**"},{"metadata":{},"cell_type":"markdown","source":"After joined with the player tracking data, the following table, including only wide receiver as PositionGroup, was created. All receivers included in the dataset were listed as injured during play:"},{"metadata":{"scrolled":false,"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/WideJoinC.csv')\ndf.head(6)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Since there was a total of one foot injury in the dataset, this single case was removed from all of the barplots below. Same as in linebackers, also wide receivers' chances of developing a knee injury instead of an ankle injury increase with play speed (presented in median value below): "},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(13.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/WideJoinC.csv', usecols = ['BodyPart', 's'])\n\n#exclude foot injury\ndf = df[df.BodyPart != 'Foot']\n\nplot = sns.barplot(\n    data=df ,\n    x='BodyPart' ,\n    y='s',\n    estimator= np.median\n )\n\nplot.axes.set_title('FIGURE 8: wide receiver injuries: BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel('Body Part',fontsize=18)\nplot.set_ylabel('Median Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplt.show()\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"In the dataset, wide receivers' median speed shows up affecting them injury-wise in punt returns. As returning punts is not plays most wide receivers usually line up, it is probable that at least some wide receivers included in the injury dataset are by and large members of special teams with only occasional plays in offense. This is in itself significant, because it further emphasizes the role of special team plays in the provided injury dataset."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(16.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/WideJoinC.csv', usecols = ['BodyPart', 'PlayType', 's'])\n\n#exclude foot injuries\ndf = df[df.BodyPart != 'Foot']\n\nplot = sns.barplot(\n    data=df ,\n    x='PlayType' ,\n    y='s',\n     estimator= np.median,\n    hue = 'BodyPart'   \n )\n\nplot.axes.set_title('FIGURE 9: wide receivers divided by PlayType, BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel('Play Type',fontsize=18)\nplot.set_ylabel('Median Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=2, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\n\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The following play happened on synthetic surface. The receiver took off after the ball was snapped (x = 46, y = 18. for some reason there are negtive y values in the dataset). The attempted pass play turned out as play action (x = 52, y = 22), as quarterback was quickly forced to come up with another play. As the quarterback passed the ball (x = 55, y = 11), the pass arrived (x = 55, y = 8) but was eventually incomplete."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\n\nsns.set(rc={'figure.figsize':(13.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/WideRouteB.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 10: PlayerKey 42448, pass play, PlayKey 42448-14-3',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=3, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\nplt.annotate('snap', size = 14, xy=(46.2,18), xytext=(46,15), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('play action', size = 14, xy=(52,21.8), xytext=(53,18), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('pass', size = 14, xy=(55.2,11), xytext=(56,12), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('incomplete', size = 14, xy=(55.2,8), xytext=(56,4), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Adding the player orientation - the angle the player is facing - as a factor, the analysis shows that no sudden twist or angle adjustment took place while the receiver was running at full speed."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(13.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/WIdeRoute.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='time', y='s', hue = 'o', data=df)\n\nplot.axes.set_title('FIGURE 11: PlayerKey 42448, pass play, PlayKey 42448-14-3', fontsize=24)\nplot.set_xlabel('Play Time (seconds)',fontsize=18)\nplot.set_ylabel('Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=2, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 'o = player orientation')\n\nplt.annotate('snap', size = 14, xy=(5.3,0.1), xytext=(3,2), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('top speed', size = 14, xy=(9.4,7), xytext=(8.5,5), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('incomplete pass', size = 14, xy=(9.7,7), xytext=(11,6), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 3.3 Defensive back"},{"metadata":{},"cell_type":"markdown","source":"As a position group, defensive backs (strong safety, free safety) are often the last line of defense in fooball when it comes to deep passes. The provided dataset includes the following basic data on safeties and their injuries:  "},{"metadata":{},"cell_type":"markdown","source":"- **11 recorded injuries**\n- **injuries per position: SS (5), FS (5), DB (1)**\n- **main play type for injuries: pass (7)**\n- **6 injuries took place on natural surface, 5 on synthetic**\n- **an injured player participated in 10 or less plays in 3/11 cases**\n- **the average running count of plays before injury: 33.7**\n- **9/11 injuries were outdoor games (0/9 had rain)**\n- **5 injuries were ankle injuries, 6 knee injuries**\n- **4 injuries lead to missing 42 or more days**\n- **5 injuries lead to missing 28 or more days**"},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/SafetyJoinC.csv')\ndf.head(6)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Compared to for example wider receivers, players on strong safety position suffer from ankle injuries more often when speed is increased."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/SafetyJoinC.csv', usecols = ['BodyPart', 's'])\n\n\nplot = sns.barplot(\n    data=df ,\n    x='BodyPart' ,\n    y='s',\n    estimator= np.median\n )\n\nplot.axes.set_title('FIGURE 12: Defensive back injuries: BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel('Body Part',fontsize=18)\nplot.set_ylabel('Median Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"When divided between different play types, ankle and knee injuries were divided between punt and pass plays. However it is good to keep in mind that the provided dataset offered only eleven of five cases of confirmed defensive back injuries."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(15.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/SafetyJoinC.csv', usecols = ['BodyPart', 'PlayType', 's'])\n\n#case of Kickoff Not Returned excluded \ndf = df[df.PlayType != 'Kickoff Not Returned']\n\nplot = sns.barplot(\n    data=df ,\n    x='PlayType' ,\n    y='s',\n     estimator= np.median,\n    hue = 'BodyPart'   \n )\n\nplot.axes.set_title('FIGURE 13: Defensive back: PlayType, BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel('Play Type',fontsize=18)\nplot.set_ylabel('Median Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The play below that was knowingly excluded from the plot above, because it was the tagged under play type 'Kickoff Not Returned'. The play took place outdoors on synthetic surface. As the kickoff commenced, the special teams player took off from lower right corner of the image ( x = 76, y = 31). The play landed on endzone (x = 43, y = 34) after which the safety continued on top speed. This would indicated that there indeed was at least a serious possibility that the kickoff would be returned. This play sidelined the player for one week after what was later reported as a knee injury."},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\n\nsns.set(rc={'figure.figsize':(15.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/SafetyRoute.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 14: PlayerKey 47334, Kickoff Not Returned, PlayKey 47334-8-1',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=3, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\nplt.annotate('kickoff', size = 14, xy=(76,31.5), xytext=(70,33), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('ball on endzone', size = 14, xy=(43,34), xytext=(43,36), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"In another play involving injury, after the snap (x = 31, y =22) the play turned out to be a fake punt trick play (x = 37, y = 8). The play continued with player contact (x = 48, y = 2) resulting in tackle (x = 51, y = 0). It is also notable that this injury play was yet another special teams play. "},{"metadata":{"scrolled":true,"trusted":true},"cell_type":"code","source":"import numpy as np\nimport pandas as pd\nimport seaborn as sns\n\nsns.set(rc={'figure.figsize':(12.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/SafetyRouteB.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 15: PlayerKey 39850, Punt, PlayKey 39850-9-2',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=3, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\nplt.annotate('snap', size = 14, xy=(31,22.3), xytext=(34,22), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('fake punt', size = 14, xy=(37.5,8), xytext=(40,10), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('player contact', size = 14, xy=(48,2), xytext=(48,4), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('tackle', size = 14, xy=(51,0.5), xytext=(53,4), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 3.4 Cornerback"},{"metadata":{"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/CornerbackJoinC.csv')\ndf.head(6)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"There are few things in sports more physically demanding than playing cornerback in football. Taking part both in pass rush as well as pass coverage, the athleticism demanded from cornerbacks is on high level. In the dataset the following basic data concerned cornerback injuries:"},{"metadata":{},"cell_type":"markdown","source":"- **8 recorded injuries**\n- **main play type for injuries: pass (5/8)** \n- **an injured player participated in 10 or less plays in 0/7 cases**\n- **the average running count of plays before injury: 36.7**\n- **6 injuries took place on synthetic surface, 2 on natural**\n- **5 injuries were ankle injuries, 2 knee injuries, 1 foot injury**\n- **2 injuries lead to missing 42 or more days**\n- **4 injuries lead to missing 28 or more days**\n"},{"metadata":{},"cell_type":"markdown","source":"There's no distinctive difference between ankle and knee injury occurrence, since the eight cases don't really provide a solid basis for more coherent analysis."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/CornerbackJoinC.csv', usecols = ['BodyPart', 's'])\ndf = df[df.BodyPart != 'Foot']\n\nplot = sns.barplot(\n    data=df ,\n    x='BodyPart' ,\n    y='s',\n    estimator= np.median\n )\n\nplot.axes.set_title('FIGURE 16: cornerback injuries: BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel('Body Part',fontsize=18)\nplot.set_ylabel('Median Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As for play types, punt returns are a factor in top-speed cornerback plays."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndf = pd.read_csv('../input/CornerbackJoinC.csv', usecols = ['BodyPart', 'PlayType', 's'])\ndf = df[df.BodyPart != 'Foot']\n\nplot = sns.barplot(\n    data=df ,\n    x='PlayType' ,\n    y='s',\n     estimator= np.median,\n    hue = 'BodyPart'   \n )\n\nplot.axes.set_title('FIGURE 17: cornerback: PlayType, BodyPart, median speed (yd/s)',fontsize=24)\nplot.set_xlabel('Play Type',fontsize=18)\nplot.set_ylabel('Median Speed (yd/s)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The following punt play took place outdoors on synthetic surface. The ball was snapped (x = 33.13 , y = 43.09), after which the ball  was received (x  =64.21 , y = 19.08). An attempt was made to return the punt, since the play ended in a tackle (x = 77.16 , y = 15.42). Again, the play was a special teams play."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(14.7,8.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/CornerbackRoute.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 18: PlayerKey 47813, Punt return, PlayKey 47813-8-19',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\nplt.annotate('snap', size = 14, xy=(33.13,43.09), xytext=(40,40), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('ball received', size = 14, xy=(64.21,19.08), xytext=(60,27), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('tackle', size = 14, xy=(77.16,15.42), xytext=(70,20), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 3.5 Defensive linemen"},{"metadata":{},"cell_type":"markdown","source":"There are only a total of seven injury cases in the provided dataset including offensive linemen. Thus it is not sensible to try to draw any wider conclusions based on the record at hand. In general the basic data looks like this:"},{"metadata":{},"cell_type":"markdown","source":"- **7 recorded injuries**\n- **roster position per injury: DE (5), DT (2)**\n- **main play type for injuries: rush (4/7)**\n- **4 injuries took place on natural surface, 3 on synthetic surface**\n- **6/7 injuries were outdoor games (average temperature 57.5, 2/6 games had rain)**\n- **an injured player participated in 10 or less plays in 4/7 cases**\n- **the average running count of plays before injury: 16.7**\n- **2 injuries were ankle injuries, 4 knee injuries, 1 foot injury**\n- **3 injuries lead to missing 42 or more days**\n- **4 injuries lead to missing 28 or more days**"},{"metadata":{},"cell_type":"markdown","source":"Below is a graph of a defensive end rush play, which was the very first play the player took part of in the game. After the huddle, the play started with line set followed by snap (x = 68.55, y = 30.18). After the handoff there was contact (x = 69.11, y = 30.64) shortly followed by tackle (x = 69.29, y = 29.89). For the player in questions, this play lead him to miss 42 days or more. The play took place indoors on synthetic surface, and - as linemen plays almost always - it included very short bursts of top speed and power."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(13.7,10.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/DlineRouteC.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 19: PlayerKey 39678, Rush, PlayKey 39678-2-1',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=3, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\nplt.annotate('snap', size = 14, xy=(68.55,30.18), xytext=(68.3,30.1), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('handoff', size = 14, xy=(67.82,30.81), xytext=(68.2,30.6), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('contact', size = 14, xy=(69.11,30.64), xytext=(69.2,30.7), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('tackle', size = 14, xy=(69.29,29.89), xytext=(68.8,30), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 3.6 Offensive linemen"},{"metadata":{},"cell_type":"markdown","source":"The dataset consisted a total of six plays including injuries by defensive linemen. Below is the basic data in a nutshell:"},{"metadata":{},"cell_type":"markdown","source":"- **6 recorded injuries**\n- **roster position C (4), T (2)**\n- **play types for injuries: rush (3), pass (3)**\n- **4 injuries took place on natural surface, 2 on synthetic**\n- **an injured player participated in 10 or less plays in 0/6 cases**\n- **the average running count of plays before injury: 31.8**\n- **4 injuries took place in outdoor games (0/4 had rain)**\n- **3 injuries were ankle injuries, 2 foot injuries, 1 knee injury**\n- **2 injuries lead to missing 42 or more days**"},{"metadata":{},"cell_type":"markdown","source":"In the following play featuring synthetic surface and a center position player, after the snap (x = 38.69, y = 26.56) the quarterback passed the ball (x = 42.72, y = 22.44) and was received (x = 42.26, y = 22.5). The receiver went out of bounds (x = 42.22, y = 22.49) ending the play. As the graphs shows, offensive linemen are almost always out of play after the quarterback succesfully passes the ball. Thus it can be concluded that it was the short top-speed burst before the pass that caused the ankle injury, forcing the center to miss one game. "},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(13.7,10.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/OLineRouteC.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 20: PlayerKey 42406, Pass, PlayKey 42406-6-13',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\n\nplt.annotate('snap', size = 14, xy=(38.69,26.56), xytext=(39,26), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('pass', size = 14, xy=(42.72,22.44), xytext=(42.5,22), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('ball received', size = 14, xy=(42.26,22.5), xytext=(41.5,22.2), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('out of bounds', size = 14, xy=(42.22,22.49), xytext=(41,22.5), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### 3.7 Running back"},{"metadata":{},"cell_type":"markdown","source":"Running backs are often the offensive players responsible for achieving those two or three last yards to get the 1st down. There were six cases of running back injuries in the dataset:"},{"metadata":{},"cell_type":"markdown","source":"- **6 recorded injuries**\n- **main play types for injuries: rush (4), pass (2)**\n- **2 injuries took place on natural surface, 4 on synthetic**\n- **an injured player participated in 10 or less plays in 1/6 cases**\n- **the average running count of plays before injury: 17.8**\n- **4 injuries were outdoor games (1/4 had rain)**\n- **2 injuries were ankle injuries, 4 knee injuries**\n- **4 injuries lead to missing 42 or more days**\n- **5 injuries lead to missing 28 or more days**"},{"metadata":{},"cell_type":"markdown","source":"In the rush play below, taking place on natural surface, after the snap (x = 43.73, y = 32.06) the running back received the ball in handoff (x = 43.35, y = 28.64). The play continued with contact (x = 39.32, y = 6.75) followed by tackle (x = 38.51, y = 5.79). This play caused the running back to miss 28 days or more because of a knee injury."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport numpy as np\n\nsns.set(rc={'figure.figsize':(13.7,10.27)})\nsns.set(font='sans-serif')\n\ndata = '../input/RBRouteC.csv'\ndf = pd.read_csv(data, index_col=0)\n\nplot = sns.scatterplot(x='x', y='y', size = 's', hue = 's', data=df)\n\nplot.axes.set_title('FIGURE 21: PlayerKey 31070, Rush, PlayKey 31070-3-7',fontsize=24)\nplot.set_xlabel('Yards (x)',fontsize=18)\nplot.set_ylabel('Yards (y)',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplot.legend (loc=2, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1, title = 's = speed (yd/s)')\n\n\nplt.annotate('snap', size = 14, xy=(43.73,32.06), xytext=(42.5,30), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('handoff', size = 14, xy=(43.35,28.64), xytext=(42,26), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('contact', size = 14, xy=(39.32,6.75), xytext=(39,10), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\nplt.annotate('tackle', size = 14, xy=(38.51,5.79), xytext=(38,10), arrowprops=dict(arrowstyle = '->', color = 'b', connectionstyle='arc3,rad=0'))\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"In addition, there were also two injuries featuring tight ends, but they were excluded from this analysis."},{"metadata":{},"cell_type":"markdown","source":"### 4. Conclusions"},{"metadata":{},"cell_type":"markdown","source":"Out of 105 injury cases in the dataset, 28 cases did not feature data on player roster position. This left a total of 77 injury cases relevant to this analysis.\n\nOut of those 77 cases, 32 were caused by pass play. Rush plays formed 23 cases of total injuries whereas 22 injuries were special team plays such as kickoffs and punt plays.\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\ndf=pd.read_csv('../input/InjuredPlayers.csv', usecols = ['PlayType'])\n\nsns.set(font='sans-serif')\nsns.set(rc={'figure.figsize':(20.7,10.27)})\n\nplot = sns.countplot(x = 'PlayType',\n              data = df,\n              order = df['PlayType'].value_counts().index)\n\nplot.axes.set_title('FIGURE 22: total count of injuries divided by play type',fontsize=24)\nplot.set_xlabel('Play Type',fontsize=18)\nplot.set_ylabel('Total count of injuries',fontsize=18)\nplot.tick_params(labelsize=14)\n\nplt.show()\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Further divided by roster positions, the analysis returns the following result: "},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(20.7,11.27)})\nsns.set(font='sans-serif')\n\ndf=pd.read_csv('../input/InjuredPlayers.csv', usecols = ['RosterPosition', 'PlayType'])\n\nplot = sns.countplot(x = 'PlayType',\n              data = df,\n              hue = 'RosterPosition',\n              order = df['PlayType'].value_counts().index)\n\nplot.axes.set_title('FIGURE 23: total count of injuries divided by play type and roster position',fontsize=24)\nplot.set_xlabel(\"Roster Position\",fontsize=18)\nplot.set_ylabel(\"Total count of injuries\",fontsize=18)\nplot.tick_params(labelsize=14)\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As noted earlier, **when surface is taken into account, the most significant difference is in the cornerback category**. However, as mentioned in chapter 3.4, the provided dataset included a total of eight injury cases involving cornerbacks. As a sample group this is insufficient for drawing any conclusion on the correlation of roster position and playing surface."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\nsns.set(rc={'figure.figsize':(17.7,11.27)})\nsns.set(font='sans-serif')\n\ndf=pd.read_csv('../input/InjuredPlayers.csv', usecols = ['Surface', 'RosterPosition'])\n\nplot = sns.countplot(x = 'Surface',\n              data = df,\n              hue = 'RosterPosition',\n              order = df['Surface'].value_counts().index)\n\nplot.axes.set_title('FIGURE 24: total count of injuries divided by surface and roster position',fontsize=24)\nplot.set_xlabel(\"Roster Position\",fontsize=18)\nplot.set_ylabel(\"Total count of injuries\",fontsize=18)\nplot.tick_params(labelsize=14)\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The website *TeamRankings.com *provides various up-to-date statistics on NFL. Using the website it is possible to state the following:\n\n-    **in average an NFL team has had 62 plays in a single game in 2019 season (before week 15)**\n-    **a special teams player has had an average of 14 plays per game in 2019 season**\n-    **for a team, an average NFL game thus consists of 24 offensive plays, 24 defensive plays and 14 special team plays**\n-    **furthermore, an average NFL game consists of 15-16 plays per quarter**\n\n\nThe PlayKey column in the provided datasets consists of three different parts: PlayerKey-GameID-X. The X in PlayKey identifies in sequential order a player's plays in a game. Thus it is possible to see on which play the player got injured, as seen before in this analysis.\n\nCombining this with data from the provided dataset with estimated the number of plays per quarter, it is possible to predict on which quarter each player got injured. The table below consists of the 77 cases where an injury could be further identified to a specific roster position. The table has a column TheKey, which is the last two digits of the PlayKey extracted, indicating the specific number of play in the game when the player got injured. \n   "},{"metadata":{"trusted":true},"cell_type":"code","source":"df=pd.read_csv('../input/InjuryPlays.csv')\ndf.head(6)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Below is a figure with x describing the specific number of play in the game when the player got injured, and y describing the count of those same plays (how many of the 77 injuries listed in the dataset took place in that number of play)."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom matplotlib.ticker import MaxNLocator\n\n# y axle values to interger\nax = plt.figure().gca()\nax.yaxis.set_major_locator(MaxNLocator(integer=True))\n\n\ndf=pd.read_csv('../input/InjuryPlays.csv', usecols = ['BodyPart', 'TheKey'])\n\nsns.set(font='sans-serif')\nsns.set(rc={'figure.figsize':(23.7,6.27)})\n\nplot = sns.countplot(x = 'TheKey',\n              data = df,\n              hue = 'BodyPart',\n                     \n             order = df['TheKey'].value_counts().index)\n\n\n\n\nplot.axes.set_title('FIGURE 25: count of injuries in a specific number of play (body part)',fontsize=24)\nplot.set_xlabel('Number of play in game',fontsize=18)\nplot.set_ylabel('Total count of injuries',fontsize=18)\nplot.tick_params(labelsize=14)\nplot.legend (loc=1, fontsize = 16, fancybox=True, framealpha=1, shadow=True, borderpad=1)\n\nplt.show()\n\n\n\n","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The figure shows peaks both in ankle and knee injuries especially in plays 13, 16 and 18. These plays by average take place at the turn of first and second quarter. There are also a spike of knee injuries in plays 3, 6 and 7, meaning they take place right at the beginning of the game. All in all, **the first quarter is slightly overrepresented when lower leg injuries are divided between the four quarters of a football game. Especially running back and defensive linemen injuries included in the dataset took place in the beginning of the games**.\n\nFootball is basically a series of short top-speed power intervals with stagnant rest periods between the plays. This creates challenges especially for special teams player as well as wide receivers and their defenders in the secondary.\n\nTherefore one could ask the following two questions based on the injury data available:\n\n-   **has the pre-game player warm-up been sufficient before the game?**\n-    **does the pre-game warm-up take into account that special teams players 'cool down' (have less plays and thus have to wait for their turn longer in the game)?**\n"},{"metadata":{},"cell_type":"markdown","source":"However it is easy to see that **mostly the 77 injuries included in the dataset are spread evenly when play number in a game is concerned**. In the end, most NFL players do not get injured because of field surface, faulty helmet or a malicious tackle.\n\nThey get injured because they are playing modern football, the fastest contact sport of our era along with ice hockey.\n\nSpeaking of hockey, enter the final chapter of this analysis as a wild card. "},{"metadata":{},"cell_type":"markdown","source":"### 5. Afterword: lesson from NHA"},{"metadata":{},"cell_type":"markdown","source":"The ongoing season is the centennial celebration of the National Football League. **In the NFL owners meeting 11th of December 2019, projections were made for the 2020 salary cap. The figure in question was in the range of 196-201 million USD, which is is a 40-percent increase from 2015, when salary cap was 143 million dollars**.\n\nThis is a significant incentive to keep the key players healthy, since they are becoming increasingly larger an investment. ALso ticket-buying NFL fans want to see the superstars playing with their full skillset and abilities. This is however possible only if these players are not injured.\n\n\n\n\n"},{"metadata":{},"cell_type":"markdown","source":"More than a century ago, the National Hockey Association - predecessor to NHL - had a major problem. The players were getting injured way too often, leaving the stands empty when fans rather stayed home than came to watch star player substitutes."},{"metadata":{},"cell_type":"markdown","source":"Eventually NHA came up with a solution. At the time ice hockey games consisted of two 30-minute halves.  NHA team owners realized that most of their revenues came not from tickets but basically from everything else, mostly food and beverages (merchandise was not a big deal then). So NHA changed the rules to give fans more time to eat and drink. Instead of two halves, ice hockey games were made to consist of three 20-minute periods. Later the very same procedure became an international standard for ice hockey, and most national leagues today have 18-minute intermissions between periods.\n"},{"metadata":{},"cell_type":"markdown","source":"What also happened in NHA - as an unintended consequence - was that the quality of games increased significantly with the new rule. For example the surface - ice rink - could now be cleaned twice during the game."},{"metadata":{},"cell_type":"markdown","source":"Injuries recognize no garbage time, whether it's ice hockey or football. Any given minute in a game is as probable as the other for injuries to occur. Therefore **the only definite way to reduce any kind of injuries in football is to reduce the amount of time football is played in a game**."},{"metadata":{},"cell_type":"markdown","source":"In 21st Century, **four 15-minute quarters with one halftime is an obsolete format for modern, physically demanding football. Both the quality and intensity of the game would arguably increase if the game consisted of three 15-minute periods with two intermissions between them**.\n\nUnder this format also football fans would probably spend more money at the stadiums nowadays built as entertainment hubs, just like today's NHL fans do at hockey arenas. Also tv commercials would be given a whole new forum with two intermissions instead of just one halftime."},{"metadata":{},"cell_type":"markdown","source":"Time never stops for the great ones, as the late great Al Davis contended. Professional football is in need of a timeout when it comes to the future of the sport. Fans want to see their favourite players and their fantasy leagues starters healthy on the field, not in IR.\n\nThe formidable challenge for the NFL is to see that this happens in reality."}],"metadata":{"celltoolbar":"Raw Cell Format","kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.7.4"}},"nbformat":4,"nbformat_minor":1}