{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"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\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 read-only \"../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# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-10-02T17:05:39.072720Z","iopub.execute_input":"2021-10-02T17:05:39.073657Z","iopub.status.idle":"2021-10-02T17:05:39.100216Z","shell.execute_reply.started":"2021-10-02T17:05:39.073555Z","shell.execute_reply":"2021-10-02T17:05:39.099254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"missing_values = [\"n/a\", \"na\", \"--\",\"-\"] \nimport warnings\nwarnings.filterwarnings('ignore')\nimport numpy             as np\nimport pandas            as pd\npd.set_option('display.max_columns', 100)\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:16:04.436955Z","iopub.execute_input":"2021-10-02T17:16:04.437421Z","iopub.status.idle":"2021-10-02T17:16:04.442425Z","shell.execute_reply.started":"2021-10-02T17:16:04.437357Z","shell.execute_reply":"2021-10-02T17:16:04.441805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<font color = teal> <b> File descriptions </font> </b>\n\n- Game data: The games.csv contains the teams playing in each game. The key variable is gameId.\n\n- Play data: The plays.csv file contains play-level information from each game. The key variables    are gameId and playId.\n\n- Player data: The players.csv file contains player-level information from players that participated in any of the tracking data files. The key variable is nflId.\n\n- Tracking data: Files tracking[season].csv contain player tracking data from season [season]. The key variables are gameId, playId, and nflId.\n\n- PFF Scouting data: The PFFScoutingData.csv file contains play-level scouting information for each game. The key variables are gameId and playId*","metadata":{}},{"cell_type":"markdown","source":"# Importing Data in respective dataframe","metadata":{}},{"cell_type":"code","source":"players = pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/players.csv')\nPFFScoutingData= pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/PFFScoutingData.csv')\ntracking2019=pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/tracking2019.csv')\ntracking2020= pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/tracking2020.csv')\ngames= pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/games.csv')\ntracking2018= pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/tracking2018.csv')\nplays= pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/plays.csv')\n","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:05:40.055787Z","iopub.execute_input":"2021-10-02T17:05:40.056161Z","iopub.status.idle":"2021-10-02T17:07:44.933423Z","shell.execute_reply.started":"2021-10-02T17:05:40.056132Z","shell.execute_reply":"2021-10-02T17:07:44.932357Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"###  **Uncomment the dataframes to check the head() and the corr respectively.**","metadata":{}},{"cell_type":"code","source":"players.head()\n#PFFScoutingData.head()\n#tracking2019.head()\n#tracking2020.head()\n#tracking2018.head()\n#games.head()\n#plays.head()\n","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:44.934567Z","iopub.execute_input":"2021-10-02T17:07:44.934807Z","iopub.status.idle":"2021-10-02T17:07:44.961015Z","shell.execute_reply.started":"2021-10-02T17:07:44.934781Z","shell.execute_reply":"2021-10-02T17:07:44.960122Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#We will Try to find the collrelation within the respective dataset \n#so that we can find the feature that holds the key importance for further processing. \n#players.corr()\n#PFFScoutingData.corr()\ntracking2019.corr()\n#tracking2020.corr()\n#tracking2018.corr()\n#games.corr()\n#plays.corr()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:16:56.487830Z","iopub.execute_input":"2021-10-02T17:16:56.488281Z","iopub.status.idle":"2021-10-02T17:17:02.920635Z","shell.execute_reply.started":"2021-10-02T17:16:56.488239Z","shell.execute_reply":"2021-10-02T17:17:02.919740Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:44.977906Z","iopub.execute_input":"2021-10-02T17:07:44.978136Z","iopub.status.idle":"2021-10-02T17:07:44.996847Z","shell.execute_reply.started":"2021-10-02T17:07:44.978112Z","shell.execute_reply":"2021-10-02T17:07:44.996026Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players.drop(['birthDate'], axis='columns', inplace=True) ","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:44.997893Z","iopub.execute_input":"2021-10-02T17:07:44.998459Z","iopub.status.idle":"2021-10-02T17:07:45.011775Z","shell.execute_reply.started":"2021-10-02T17:07:44.998424Z","shell.execute_reply":"2021-10-02T17:07:45.010720Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#since birthdate does not play any keyfactor we will drop the  Bithdate from the dataframe\nplayers.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:45.012827Z","iopub.execute_input":"2021-10-02T17:07:45.013707Z","iopub.status.idle":"2021-10-02T17:07:45.031234Z","shell.execute_reply.started":"2021-10-02T17:07:45.013667Z","shell.execute_reply":"2021-10-02T17:07:45.030296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_style(\"darkgrid\")\nsns.displot(data=players, x=\"weight\")","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:45.032495Z","iopub.execute_input":"2021-10-02T17:07:45.032836Z","iopub.status.idle":"2021-10-02T17:07:45.585557Z","shell.execute_reply.started":"2021-10-02T17:07:45.032807Z","shell.execute_reply":"2021-10-02T17:07:45.584913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_style(\"darkgrid\")\nsns.lineplot(\n    data=players, x=\"height\", y=\"weight\", err_style=\"band\")","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:45.586577Z","iopub.execute_input":"2021-10-02T17:07:45.586963Z","iopub.status.idle":"2021-10-02T17:07:46.853691Z","shell.execute_reply.started":"2021-10-02T17:07:45.586935Z","shell.execute_reply":"2021-10-02T17:07:46.852909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players['Position'].value_counts().plot.bar(figsize=(10,8))\n\nplt.xlabel('position')\nplt.ylabel('total count')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:46.855689Z","iopub.execute_input":"2021-10-02T17:07:46.855930Z","iopub.status.idle":"2021-10-02T17:07:47.400145Z","shell.execute_reply.started":"2021-10-02T17:07:46.855903Z","shell.execute_reply":"2021-10-02T17:07:47.399360Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking2019.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:47.401318Z","iopub.execute_input":"2021-10-02T17:07:47.401575Z","iopub.status.idle":"2021-10-02T17:07:47.427688Z","shell.execute_reply.started":"2021-10-02T17:07:47.401547Z","shell.execute_reply":"2021-10-02T17:07:47.426991Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking2019.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:47.429232Z","iopub.execute_input":"2021-10-02T17:07:47.429774Z","iopub.status.idle":"2021-10-02T17:07:55.552626Z","shell.execute_reply.started":"2021-10-02T17:07:47.429701Z","shell.execute_reply":"2021-10-02T17:07:55.551786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tracking2019.dropna(inplace=True) ","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:07:55.554000Z","iopub.execute_input":"2021-10-02T17:07:55.554500Z","iopub.status.idle":"2021-10-02T17:08:05.112199Z","shell.execute_reply.started":"2021-10-02T17:07:55.554456Z","shell.execute_reply":"2021-10-02T17:08:05.111399Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.displot(data=tracking2019, x=\"position\")","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:08:05.113302Z","iopub.execute_input":"2021-10-02T17:08:05.113577Z","iopub.status.idle":"2021-10-02T17:08:25.256406Z","shell.execute_reply.started":"2021-10-02T17:08:05.113547Z","shell.execute_reply":"2021-10-02T17:08:25.255493Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axs = plt.subplots(2, 2, figsize=(7, 7))\n\nsns.histplot(data=tracking2019, x=\"x\", kde=True, color=\"skyblue\", ax=axs[0, 0])\nsns.histplot(data=tracking2019, x=\"o\", kde=True, color=\"olive\", ax=axs[0, 1])\nsns.histplot(data=tracking2019, x=\"dir\", kde=True, color=\"gold\", ax=axs[1, 0])\nsns.histplot(data=tracking2019, x=\"y\", kde=True, color=\"teal\", ax=axs[1, 1])\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-02T17:18:01.926680Z","iopub.execute_input":"2021-10-02T17:18:01.926950Z","iopub.status.idle":"2021-10-02T17:21:51.503809Z","shell.execute_reply.started":"2021-10-02T17:18:01.926923Z","shell.execute_reply":"2021-10-02T17:21:51.503173Z"},"trusted":true},"execution_count":null,"outputs":[]}]}