{"cells":[{"metadata":{},"cell_type":"markdown","source":"# NFL 1st and Future - Analytics\n### Can you investigate the relationship between the playing surface and the injury and performance of NFL athletes?\n\nIn this challenge, you're tasked to investigate the relationship between the playing surface and the injury and performance of National Football League (NFL) athletes and to examine factors that may contribute to lower extremity injuries.\n\n![nfl.png](https://1ycbx02rgnsa1i87hd1i7v1r-wpengine.netdna-ssl.com/wp-content/uploads/2019/01/nfl.png)\n\n### The Challenge\n\nIn the NFL, 12 stadiums have fields with synthetic turf. Recent investigations of lower limb injuries among football athletes have indicated significantly higher injury rates on synthetic turf compared with natural turf (Mack et al., 2018; Loughran et al., 2019). In conjunction with the epidemiologic investigations, biomechanical studies of football cleat-surface interactions have shown that synthetic turf surfaces do not release cleats as readily as natural turf and may contribute to the incidence of non-contact lower limb injuries (Kent et al., 2015). Given these differences in cleat-turf interactions, it has yet to be determined whether player movement patterns and other measures of player performance differ across playing surfaces and how these may contribute to the incidence of lower limb injury."},{"metadata":{"trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n\n%matplotlib inline\n\n# Read the input files\nplaylist = pd.read_csv('../input/nfl-playing-surface-analytics/PlayList.csv')\ninj = pd.read_csv('../input/nfl-playing-surface-analytics/InjuryRecord.csv')\ntrk = pd.read_csv('../input/nfl-playing-surface-analytics/PlayerTrackData.csv')\n\ndef change_width(ax, new_value) :\n    for patch in ax.patches :\n        current_width = patch.get_width()\n        diff = current_width - new_value\n\n        # we change the bar width\n        patch.set_width(new_value)\n\n        # we recenter the bar\n        patch.set_x(patch.get_x() + diff * .5)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Which body part gets mostly injured?"},{"metadata":{"trusted":true},"cell_type":"code","source":"f,ax=plt.subplots(figsize=(13,8))\nsns.countplot(inj['BodyPart'],palette=sns.color_palette(\"Blues_d\"))\n\nchange_width(ax,.55)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Knee and Ankle is more prone to get injured than other lower limb body parts.\n\nBut, on which field type does injuries occur more often?"},{"metadata":{"trusted":true},"cell_type":"code","source":"sns.countplot(y=inj['Surface'],palette=sns.color_palette(\"Blues_d\"))","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Synthetic surface causes more injuries than natural surface. But the difference is not much.\n\nLet's look deep into which surface causes what type of injuries"},{"metadata":{"trusted":true},"cell_type":"code","source":"f,ax=plt.subplots(figsize=(16,8))\nsns.countplot(x=inj['Surface'],hue=inj['BodyPart'])","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Let's see which surface causes long term injuries"},{"metadata":{"trusted":true},"cell_type":"code","source":"d = inj.iloc[:,5:]\n\nd=d.sum(axis=1)\nd.sort_values(inplace=True)\nd.replace(1,'DM_M1',inplace=True)\nd.replace(2,'DM_M7',inplace=True)\nd.replace(3,'DM_M28',inplace=True)\nd.replace(4,'DM_M42',inplace=True)\n\nf,ax=plt.subplots(figsize=(12,8))\nsns.countplot(x=inj['Surface'],hue=d)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Synthetic turf causes more severe injuries compared to Natural turf.\n\nLet's see which type of injuries are more severe"},{"metadata":{"trusted":true},"cell_type":"code","source":"f,ax=plt.subplots(figsize=(12,8))\nsns.countplot(x=inj['BodyPart'],hue=d)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"\n\n**Conclusion**\n1. Knee and Ankle injury occur most often\n2. Synthetic surface is more prone to injury\n3. Synthetic turf causes more severe injuries compared to Natural turf\n4. Knee and Ankle injuries can be minor or severe. where as Foot injury is moslty severe and takes longer time to heal in all the cases.\n\nBut the numbers of injuries based on type of turf don't differ much. It will be interesting to see how Player Movement affect injuries.\n\n**To Be Continued..**"}],"metadata":{"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.1"}},"nbformat":4,"nbformat_minor":1}