{"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-12-26T05:26:43.619752Z","iopub.execute_input":"2021-12-26T05:26:43.620068Z","iopub.status.idle":"2021-12-26T05:26:43.631365Z","shell.execute_reply.started":"2021-12-26T05:26:43.620033Z","shell.execute_reply":"2021-12-26T05:26:43.630455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib.cm as cm\nfrom matplotlib.colors import rgb2hex\n%matplotlib inline\nimport seaborn as sns\n\n#(Credit for the below code goes to @ANZ check out his notebook as well)\ncmap = cm.get_cmap('GnBu',12) #colormap and number\ncol_def =[]\nfor i in range(cmap.N):\n    rgb = cmap(i)[:3]\n    col_def.append(rgb2hex(rgb))\n    print(rgb2hex(rgb))","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:43.633356Z","iopub.execute_input":"2021-12-26T05:26:43.633687Z","iopub.status.idle":"2021-12-26T05:26:44.367163Z","shell.execute_reply.started":"2021-12-26T05:26:43.633605Z","shell.execute_reply":"2021-12-26T05:26:44.366524Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Players Data","metadata":{}},{"cell_type":"code","source":"players = pd.read_csv('../input/nfl-big-data-bowl-2022/players.csv')\nplayers","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:44.368184Z","iopub.execute_input":"2021-12-26T05:26:44.368714Z","iopub.status.idle":"2021-12-26T05:26:44.417017Z","shell.execute_reply.started":"2021-12-26T05:26:44.368680Z","shell.execute_reply":"2021-12-26T05:26:44.416154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Data Cleaning","metadata":{}},{"cell_type":"code","source":"players.info()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:44.419012Z","iopub.execute_input":"2021-12-26T05:26:44.419243Z","iopub.status.idle":"2021-12-26T05:26:44.442112Z","shell.execute_reply.started":"2021-12-26T05:26:44.419213Z","shell.execute_reply":"2021-12-26T05:26:44.441283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**There seem to be NaN values in birthDate and collegeName. Let's get rid of the NaNs in birthdate, and create cols for birth year and birth month.**","metadata":{}},{"cell_type":"code","source":"players.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:44.443572Z","iopub.execute_input":"2021-12-26T05:26:44.443995Z","iopub.status.idle":"2021-12-26T05:26:44.460750Z","shell.execute_reply.started":"2021-12-26T05:26:44.443961Z","shell.execute_reply":"2021-12-26T05:26:44.459978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players[\"birthYear\"] = 0\nplayers[\"birthMonth\"] = 0\n#There are NA values in birthDate so that we should drop them\nplayers.dropna(subset=[\"birthDate\"], inplace=True)\nfor idx, row in players.iterrows():\n    if len(row['birthDate'].split('/')) == 3: # 05/17/1994 \n        players.loc[idx, 'birthYear'] = row['birthDate'].split('/')[2]\n        players.loc[idx, 'birthMonth'] = row['birthDate'].split('/')[0]\n        \n    elif len(row['birthDate'].split('-')) == 3: # 1995-05-05\n        players.loc[idx, 'birthYear'] = row['birthDate'].split('-')[0]\n        players.loc[idx, 'birthMonth'] = row['birthDate'].split('-')[1]","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:44.462037Z","iopub.execute_input":"2021-12-26T05:26:44.462935Z","iopub.status.idle":"2021-12-26T05:26:46.595922Z","shell.execute_reply.started":"2021-12-26T05:26:44.462884Z","shell.execute_reply":"2021-12-26T05:26:46.594949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:46.597468Z","iopub.execute_input":"2021-12-26T05:26:46.597727Z","iopub.status.idle":"2021-12-26T05:26:46.608103Z","shell.execute_reply.started":"2021-12-26T05:26:46.597695Z","shell.execute_reply":"2021-12-26T05:26:46.607351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Converting heights to CM and weights to Kg**","metadata":{}},{"cell_type":"code","source":"players_heights = players[\"height\"] # Get the Height data from DataFrame\nplayers_heights = players_heights.apply(lambda x: x.split(\"-\")) # Split the heights by hyphen (\"-\")\n\n# Convert Heights to Centimeters and add them to DataFrame\nplayers[\"height\"] = players_heights.apply(lambda x: int(x[0]) * 12 + int(x[1]) if len(x) == 2 else int(x[0])) * 2.54\n\n# Convert Weights to Kilograms and them to DataFrame\nplayers[\"weight\"] = round(players.weight * 0.453592, 2)\n\nplayers","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:46.609619Z","iopub.execute_input":"2021-12-26T05:26:46.609842Z","iopub.status.idle":"2021-12-26T05:26:46.645984Z","shell.execute_reply.started":"2021-12-26T05:26:46.609813Z","shell.execute_reply":"2021-12-26T05:26:46.645220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players.info()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:46.647145Z","iopub.execute_input":"2021-12-26T05:26:46.647970Z","iopub.status.idle":"2021-12-26T05:26:46.664983Z","shell.execute_reply.started":"2021-12-26T05:26:46.647929Z","shell.execute_reply":"2021-12-26T05:26:46.664201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Now the data is ready to work with. Everything is neat and tidy🥳🥳**","metadata":{}},{"cell_type":"markdown","source":"## Time For Some EDA on Players DataSet","metadata":{}},{"cell_type":"code","source":"len(players['displayName'].unique())","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:46.669486Z","iopub.execute_input":"2021-12-26T05:26:46.669766Z","iopub.status.idle":"2021-12-26T05:26:46.676762Z","shell.execute_reply.started":"2021-12-26T05:26:46.669734Z","shell.execute_reply":"2021-12-26T05:26:46.676009Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Let's get some data on the colleges**","metadata":{}},{"cell_type":"code","source":"college_df = players['collegeName'].value_counts()\nsns.set_style('darkgrid')\nfig, axes = plt.subplots(1,2,figsize=(12,6))\naxes[0] = sns.barplot(x=college_df[:10].values, y=college_df[:10].index, edgecolor=\"black\",palette=col_def, ax=axes[0])\naxes[0].set_title(\"Top 10 College player counts\", fontsize=20)\naxes[1].pie(x= college_df[:10], labels = college_df[:10].index, colors=col_def, autopct='%.0f%%',\n           explode=[0.03 for i in college_df[:10].index])\naxes[1].add_artist(plt.Circle((0,0),0.4,fc='white'))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:46.678019Z","iopub.execute_input":"2021-12-26T05:26:46.678254Z","iopub.status.idle":"2021-12-26T05:26:47.231754Z","shell.execute_reply.started":"2021-12-26T05:26:46.678225Z","shell.execute_reply":"2021-12-26T05:26:47.230629Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**From the above graph, we can see that, Alabama is at the top with approximately 68 players.**","metadata":{}},{"cell_type":"markdown","source":"**Postions played by players**","metadata":{}},{"cell_type":"code","source":"pos_df = players['Position'].value_counts()\nsns.set_style('darkgrid')\nfig, axes = plt.subplots(1,2,figsize=(12,6))\naxes[0] = sns.barplot(x=pos_df[:10].values, y=pos_df[:10].index, edgecolor=\"black\",palette=col_def, ax=axes[0])\naxes[0].set_title(\"Top 10 Postions played by player (By Count)\", fontsize=20)\naxes[1].pie(x= pos_df[:10], labels = pos_df[:10].index, colors=col_def, autopct='%.0f%%',\n           explode=[0.03 for i in pos_df[:10].index])\naxes[1].add_artist(plt.Circle((0,0),0.4,fc='white'))\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:47.233328Z","iopub.execute_input":"2021-12-26T05:26:47.233989Z","iopub.status.idle":"2021-12-26T05:26:47.705286Z","shell.execute_reply.started":"2021-12-26T05:26:47.233949Z","shell.execute_reply":"2021-12-26T05:26:47.704242Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**The postion 'WR' is played the most by the players. It is approximately 320 i.e is 16%**","metadata":{}},{"cell_type":"code","source":"plt.figure(figsize=(10, 6), dpi=100)\nsns.regplot(x=players.weight, y=players.height, line_kws={\"color\": \"red\"})\nplt.title(\"Player Weight(Kg) vs Player Height(cm)\");","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:47.708376Z","iopub.execute_input":"2021-12-26T05:26:47.709129Z","iopub.status.idle":"2021-12-26T05:26:48.356071Z","shell.execute_reply.started":"2021-12-26T05:26:47.709092Z","shell.execute_reply":"2021-12-26T05:26:48.344346Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**It looks like the taller the player is the heavier he is.**","metadata":{}},{"cell_type":"markdown","source":"**Weight and Height Distribution.**","metadata":{}},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 15), dpi=80)\n\nax1 = fig.add_subplot(223)\nsns.histplot(players.weight, ax=ax1)\nax1.set_title(\"Weight(Kg) Distribution\")\n\nax2 = fig.add_subplot(224)\nsns.histplot(players.height, ax=ax2, bins=10)\nax2.set_title(\"Height(cm) Distribution\");","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:48.357253Z","iopub.execute_input":"2021-12-26T05:26:48.357803Z","iopub.status.idle":"2021-12-26T05:26:49.095441Z","shell.execute_reply.started":"2021-12-26T05:26:48.357766Z","shell.execute_reply":"2021-12-26T05:26:49.094341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**From the above distribution, we can see that most of the players are between 190cm - 195cm height(390+310 = 700 approximately). Players who are on the shorter side i.e < 170cm are very less roughly 30 in count. Same is with the taller side i.e 200cm - 205cm, And most players are seen to be in between 80kg to 100. Very less people on both the extremes.**","metadata":{}},{"cell_type":"markdown","source":"**Player birthyear and birthmonth Distribution**","metadata":{}},{"cell_type":"code","source":"fig = plt.figure(figsize=(20, 15), dpi=80)\n\nbirthyear = players['birthYear'].value_counts()\nax1 = fig.add_subplot(223)\nsns.barplot(x=birthyear.index, y=birthyear.values, ci=None, ax=ax1)\nax1.tick_params(axis='x', rotation=45)\nax1.set_title(\"BirthYear Distribution\",size=20)\nplt.xlabel(\"Year\", size=15)\n\nbirthmonth = players['birthMonth'].value_counts()\nax2 = fig.add_subplot(224)\nsns.barplot(x=birthmonth.index, y=birthmonth.values, ci=None, ax=ax2)\nax2.set_title(\"BirthMonth Distribution\",size=20)\nplt.xlabel(\"Month\",size=15);","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:49.096861Z","iopub.execute_input":"2021-12-26T05:26:49.097165Z","iopub.status.idle":"2021-12-26T05:26:50.082946Z","shell.execute_reply.started":"2021-12-26T05:26:49.097123Z","shell.execute_reply":"2021-12-26T05:26:50.081745Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**From the above charts, it can be determined that most players are born in the year 1995. The most frequent birth month is September.**","metadata":{}},{"cell_type":"markdown","source":"### Game data","metadata":{}},{"cell_type":"code","source":"games = pd.read_csv(\"../input/nfl-big-data-bowl-2022/games.csv\")\ngames.head()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.084366Z","iopub.execute_input":"2021-12-26T05:26:50.085051Z","iopub.status.idle":"2021-12-26T05:26:50.108082Z","shell.execute_reply.started":"2021-12-26T05:26:50.084997Z","shell.execute_reply":"2021-12-26T05:26:50.107404Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"games.info()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.109303Z","iopub.execute_input":"2021-12-26T05:26:50.109847Z","iopub.status.idle":"2021-12-26T05:26:50.125048Z","shell.execute_reply.started":"2021-12-26T05:26:50.109787Z","shell.execute_reply":"2021-12-26T05:26:50.123939Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Making sure that the gameDate doesn't have any null values in the form of '0' or '0/0/0'**","metadata":{}},{"cell_type":"code","source":"print(games[games['gameDate'] == '0'])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.127583Z","iopub.execute_input":"2021-12-26T05:26:50.128268Z","iopub.status.idle":"2021-12-26T05:26:50.137891Z","shell.execute_reply.started":"2021-12-26T05:26:50.128218Z","shell.execute_reply":"2021-12-26T05:26:50.136688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(games[games['gameDate'] == '0/0/0'])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.139642Z","iopub.execute_input":"2021-12-26T05:26:50.140497Z","iopub.status.idle":"2021-12-26T05:26:50.151981Z","shell.execute_reply.started":"2021-12-26T05:26:50.140446Z","shell.execute_reply":"2021-12-26T05:26:50.150936Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Making sure that gameTimeEastern doesn't have any null values in forms like '0' or '0:0:0'**","metadata":{}},{"cell_type":"code","source":"print(games[games['gameTimeEastern'] == '0'])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.153240Z","iopub.execute_input":"2021-12-26T05:26:50.154061Z","iopub.status.idle":"2021-12-26T05:26:50.166146Z","shell.execute_reply.started":"2021-12-26T05:26:50.154010Z","shell.execute_reply":"2021-12-26T05:26:50.165075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(games[games['gameTimeEastern'] == '0:0:0'])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.167480Z","iopub.execute_input":"2021-12-26T05:26:50.168348Z","iopub.status.idle":"2021-12-26T05:26:50.179265Z","shell.execute_reply.started":"2021-12-26T05:26:50.168297Z","shell.execute_reply":"2021-12-26T05:26:50.178471Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Now that we are sure let's get on with some EDA on games data**","metadata":{}},{"cell_type":"code","source":"games.describe()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.180921Z","iopub.execute_input":"2021-12-26T05:26:50.181462Z","iopub.status.idle":"2021-12-26T05:26:50.208205Z","shell.execute_reply.started":"2021-12-26T05:26:50.181411Z","shell.execute_reply":"2021-12-26T05:26:50.207525Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nsns.countplot(x=games['season'], hue=games['week'])\nplt.title('Game count per Season');","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.209172Z","iopub.execute_input":"2021-12-26T05:26:50.209762Z","iopub.status.idle":"2021-12-26T05:26:50.806873Z","shell.execute_reply.started":"2021-12-26T05:26:50.209726Z","shell.execute_reply":"2021-12-26T05:26:50.805881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nhome = games['homeTeamAbbr'].value_counts()\nsns.barplot(x=home.index, y=home.values, ci=None)\nplt.xlabel(\"Home Team\")\nplt.ylabel(\"Count\")\nplt.xticks(rotation=90);","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:50.808843Z","iopub.execute_input":"2021-12-26T05:26:50.809480Z","iopub.status.idle":"2021-12-26T05:26:51.440432Z","shell.execute_reply.started":"2021-12-26T05:26:50.809431Z","shell.execute_reply":"2021-12-26T05:26:51.439358Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**It seems like there are 33 teams, but after researching and hearing from people I understood that OAK and LV are the same team. The OAK(originally) moved to LV(Las Vegas). This was not mentioned in the dataset, but I am happy that I got around it. If we add up the couts of OAK and LV I think they got the same opurtunity as the other teams.**","metadata":{}},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nvisitor = games['visitorTeamAbbr'].value_counts()\nsns.barplot(x=visitor.index, y=visitor.values, ci=None)\nplt.xlabel(\"Visitor Team\")\nplt.ylabel(\"Count\")\nplt.xticks(rotation=90);","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:51.441758Z","iopub.execute_input":"2021-12-26T05:26:51.442002Z","iopub.status.idle":"2021-12-26T05:26:52.089377Z","shell.execute_reply.started":"2021-12-26T05:26:51.441970Z","shell.execute_reply":"2021-12-26T05:26:52.088381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Same case here as well if we add up the couts of OAK and LV it would be same as the rest. So everybody got equal chances (almost)**","metadata":{}},{"cell_type":"markdown","source":"### Plays Data","metadata":{}},{"cell_type":"code","source":"plays = pd.read_csv('../input/nfl-big-data-bowl-2022/plays.csv')\nplays.head()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:52.090793Z","iopub.execute_input":"2021-12-26T05:26:52.091292Z","iopub.status.idle":"2021-12-26T05:26:52.245798Z","shell.execute_reply.started":"2021-12-26T05:26:52.091258Z","shell.execute_reply":"2021-12-26T05:26:52.244897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plays.info()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:52.249313Z","iopub.execute_input":"2021-12-26T05:26:52.250083Z","iopub.status.idle":"2021-12-26T05:26:52.280808Z","shell.execute_reply.started":"2021-12-26T05:26:52.250032Z","shell.execute_reply":"2021-12-26T05:26:52.279763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nsns.scatterplot(x='quarter', y='down', data=plays)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:52.284953Z","iopub.execute_input":"2021-12-26T05:26:52.285205Z","iopub.status.idle":"2021-12-26T05:26:52.635455Z","shell.execute_reply.started":"2021-12-26T05:26:52.285173Z","shell.execute_reply":"2021-12-26T05:26:52.634739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\ng = sns.barplot(x='quarter', y='yardsToGo', data=plays, ci=None)\ng.bar_label(g.containers[0])\nplt.title('Yards to Go in Each Quarter', size=15)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:52.636895Z","iopub.execute_input":"2021-12-26T05:26:52.637803Z","iopub.status.idle":"2021-12-26T05:26:52.876441Z","shell.execute_reply.started":"2021-12-26T05:26:52.637754Z","shell.execute_reply":"2021-12-26T05:26:52.875413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\ng = sns.barplot(x='quarter', y='playResult', data=plays, ci=None)\ng.bar_label(g.containers[0])\nplt.title(\"Play result for every quarter\", size=15)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:52.878430Z","iopub.execute_input":"2021-12-26T05:26:52.878820Z","iopub.status.idle":"2021-12-26T05:26:53.126334Z","shell.execute_reply.started":"2021-12-26T05:26:52.878764Z","shell.execute_reply":"2021-12-26T05:26:53.125329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nsns.distplot(plays['kickLength'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:53.128155Z","iopub.execute_input":"2021-12-26T05:26:53.128522Z","iopub.status.idle":"2021-12-26T05:26:53.672890Z","shell.execute_reply.started":"2021-12-26T05:26:53.128445Z","shell.execute_reply":"2021-12-26T05:26:53.671841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plays['kickLength'].describe()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:53.674614Z","iopub.execute_input":"2021-12-26T05:26:53.674971Z","iopub.status.idle":"2021-12-26T05:26:53.686953Z","shell.execute_reply.started":"2021-12-26T05:26:53.674924Z","shell.execute_reply":"2021-12-26T05:26:53.686182Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"The mean kick length is 54.744166. The minimum is 2.000 and the max is 90.000.","metadata":{}},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nsns.histplot(plays['passResult'])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:53.688232Z","iopub.execute_input":"2021-12-26T05:26:53.689196Z","iopub.status.idle":"2021-12-26T05:26:53.918521Z","shell.execute_reply.started":"2021-12-26T05:26:53.689145Z","shell.execute_reply":"2021-12-26T05:26:53.917728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plays['passResult'].describe()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:53.919817Z","iopub.execute_input":"2021-12-26T05:26:53.920817Z","iopub.status.idle":"2021-12-26T05:26:53.932062Z","shell.execute_reply.started":"2021-12-26T05:26:53.920773Z","shell.execute_reply":"2021-12-26T05:26:53.931109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = plt.figure(figsize=(12,6))\nsns.histplot(plays['possessionTeam'])\nplt.xticks(rotation=90)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:53.933319Z","iopub.execute_input":"2021-12-26T05:26:53.933595Z","iopub.status.idle":"2021-12-26T05:26:54.531727Z","shell.execute_reply.started":"2021-12-26T05:26:53.933557Z","shell.execute_reply":"2021-12-26T05:26:54.530577Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\nimport plotly.graph_objects as pg\nfrom plotly import tools as tl","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:54.533194Z","iopub.execute_input":"2021-12-26T05:26:54.533425Z","iopub.status.idle":"2021-12-26T05:26:54.537561Z","shell.execute_reply.started":"2021-12-26T05:26:54.533393Z","shell.execute_reply":"2021-12-26T05:26:54.536449Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tr18 = pd.read_csv(\"../input/nfl-big-data-bowl-2022/tracking2018.csv\")\ntr18.head()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:26:54.539170Z","iopub.execute_input":"2021-12-26T05:26:54.539691Z","iopub.status.idle":"2021-12-26T05:27:44.216230Z","shell.execute_reply.started":"2021-12-26T05:26:54.539654Z","shell.execute_reply":"2021-12-26T05:27:44.214657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = tr18.query('playId == 36 and gameId == 2018123000')\nprint(data[[\"x\", \"y\", \"team\"]])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:31:33.495474Z","iopub.execute_input":"2021-12-26T05:31:33.496457Z","iopub.status.idle":"2021-12-26T05:31:33.660678Z","shell.execute_reply.started":"2021-12-26T05:31:33.496396Z","shell.execute_reply":"2021-12-26T05:31:33.659631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(data, x='x', y='y', color='team')\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:32:29.891328Z","iopub.execute_input":"2021-12-26T05:32:29.892093Z","iopub.status.idle":"2021-12-26T05:32:31.173339Z","shell.execute_reply.started":"2021-12-26T05:32:29.892043Z","shell.execute_reply":"2021-12-26T05:32:31.172455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = tr18.query('playId == 36 and gameId == 2018102107')\nprint(data[[\"x\", \"y\", \"team\"]])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:34:20.910357Z","iopub.execute_input":"2021-12-26T05:34:20.910761Z","iopub.status.idle":"2021-12-26T05:34:20.987585Z","shell.execute_reply.started":"2021-12-26T05:34:20.910721Z","shell.execute_reply":"2021-12-26T05:34:20.986710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(data, x=\"x\", y=\"y\", color=\"team\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:34:29.689750Z","iopub.execute_input":"2021-12-26T05:34:29.690610Z","iopub.status.idle":"2021-12-26T05:34:29.780400Z","shell.execute_reply.started":"2021-12-26T05:34:29.690554Z","shell.execute_reply":"2021-12-26T05:34:29.779376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = tr18.query('position == \"CB\" and gameId == 2018111900')\nprint(data[[\"x\", \"y\", \"team\"]])","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:34:44.413745Z","iopub.execute_input":"2021-12-26T05:34:44.414331Z","iopub.status.idle":"2021-12-26T05:34:44.868245Z","shell.execute_reply.started":"2021-12-26T05:34:44.414293Z","shell.execute_reply":"2021-12-26T05:34:44.867245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(data, x=\"x\", y=\"y\", color=\"team\")\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-12-26T05:35:11.752351Z","iopub.execute_input":"2021-12-26T05:35:11.752704Z","iopub.status.idle":"2021-12-26T05:35:11.852260Z","shell.execute_reply.started":"2021-12-26T05:35:11.752669Z","shell.execute_reply":"2021-12-26T05:35:11.851572Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Well that's it for the notebook. I hope that you were able to make things out of this. Anyway if you liked this notebook then don't forget to leave an upvote as it is free**😋😉","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}