{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":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)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"First, let's see the InjuryRecord.csv."},{"metadata":{"trusted":true},"cell_type":"code","source":"inj=pd.read_csv('/kaggle/input/nfl-playing-surface-analytics/InjuryRecord.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"inj.head(3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"raw","source":"Converting one-hot-encoding to value of days missed due to injury."},{"metadata":{"trusted":true},"cell_type":"code","source":"inj['DM_SUM']=inj['DM_M1']+inj['DM_M7']*6+inj['DM_M28']*21+inj['DM_M42']*14\ninj.drop(columns=['DM_M1','DM_M7','DM_M28','DM_M42'])","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Let's see an influence by surfacee."},{"metadata":{"trusted":true},"cell_type":"code","source":"inj.groupby(['Surface'])['DM_SUM'].describe()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As for the number of days missed due to injury, synthetic turf is bigger than natural turf. "},{"metadata":{"trusted":true},"cell_type":"code","source":"inj.groupby(['Surface','BodyPart'])['DM_SUM'].describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"wall=inj.groupby(['Surface','BodyPart'])['DM_SUM'].describe()\n# Cut the parameters which number of samples is lower than 5. \nwall.loc[wall['count']>5]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"As for the mean value of the table above, there are differences about Ankle and Knee by the Surface(Natural or Synthetic). \n\nEspecially, players must take care of thier ankle when they play on synthetic turf."},{"metadata":{},"cell_type":"markdown","source":"Next, let's check PlayList.csv."},{"metadata":{"trusted":true},"cell_type":"code","source":"ply=pd.read_csv('/kaggle/input/nfl-playing-surface-analytics/PlayList.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"ply.head(3)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"I would like to merge injury data and playlist data."},{"metadata":{"trusted":true},"cell_type":"code","source":"inj_ply=pd.merge(inj,ply)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"inj_ply.groupby(['Surface','BodyPart','PlayType'])['DM_SUM'].describe()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Let's see the number of days player missed from the aspect of position and turf."},{"metadata":{"trusted":true},"cell_type":"code","source":"pos=inj_ply.groupby(['Surface','PositionGroup'])['DM_SUM'].describe()\npos.loc[pos['count']>5]","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"The insight from the table above is that injury is occuring regardless of whether turf is Synthetic or Natural.\nBut, it looks like the number of days missed is influenced by the type of turf.\n\nAs for Ankle, number of days missed by Rush play on Synthetic turf is 17.428571, on Natural turf is 9.428571.\nAs for Knee, number of days missed by Pass play on Synthetic turf is 16.333333, on Natural turf is 9.125000.\n\nAnd, regarding position, positions that player easily be injured are DB, LB, and WR.\nfor those 3 positions on synthetic turf, the number of days player missed is longer than natural turf.\n\nI need to look into player's play for details."},{"metadata":{"trusted":true},"cell_type":"code","source":"trc=pd.read_csv('/kaggle/input/nfl-playing-surface-analytics/PlayerTrackData.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"trc.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":1}