{"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":"markdown","source":"<h1><center>Exploratory Data Analysis with NFL Big Data Bowl 2022.</center></h1>\n","metadata":{}},{"cell_type":"markdown","source":"\n\n<center><img src=\"https://operations.nfl.com/media/3607/big-data-bowl_baked.jpg?anchor=center&mode=crop&width=1417&height=740&rnd=131956651790000000&quality=85\"></center>","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np \nimport plotly.express as px\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objs as go\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"_kg_hide-input":false,"execution":{"iopub.status.busy":"2021-09-28T03:25:25.409633Z","iopub.execute_input":"2021-09-28T03:25:25.409987Z","iopub.status.idle":"2021-09-28T03:25:27.666549Z","shell.execute_reply.started":"2021-09-28T03:25:25.409902Z","shell.execute_reply":"2021-09-28T03:25:27.665639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"1\"></a>\n<h2 style='background:transparent; border:0; color:black'><center>1. Game Data<center><h2>","metadata":{}},{"cell_type":"markdown","source":"### **Game data:** The games.csv contains the teams playing in each game. The key variable is gameId.\n\n* **gameId:** Game identifier, unique (numeric)\n\n* **gameDate:** Game Date (time, mm/dd/yyyy)\n\n* **gameTimeEastern:** Start time of game (time, HH:MM:SS, EST)\n\n* **homeTeamAbbr:** Home team three-letter code (text)\n\n* **visitorTeamAbbr:** Visiting team three-letter code (text)\n\n* **week:** Week of game (numeric)","metadata":{}},{"cell_type":"code","source":"games = pd.read_csv('../input/nfl-big-data-bowl-2022/games.csv')\ngames","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:27.667997Z","iopub.execute_input":"2021-09-28T03:25:27.668253Z","iopub.status.idle":"2021-09-28T03:25:27.707026Z","shell.execute_reply.started":"2021-09-28T03:25:27.668227Z","shell.execute_reply":"2021-09-28T03:25:27.706005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(games.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:27.708154Z","iopub.execute_input":"2021-09-28T03:25:27.708406Z","iopub.status.idle":"2021-09-28T03:25:27.717714Z","shell.execute_reply.started":"2021-09-28T03:25:27.708377Z","shell.execute_reply":"2021-09-28T03:25:27.716361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"games['season'].value_counts().plot.pie(figsize=(12,18),explode=(0.1,0.1,0.1),autopct=\"%1.1f%%\")\nplt.title('games player per year (season)',fontsize=18)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:27.720853Z","iopub.execute_input":"2021-09-28T03:25:27.721587Z","iopub.status.idle":"2021-09-28T03:25:27.9172Z","shell.execute_reply.started":"2021-09-28T03:25:27.721537Z","shell.execute_reply":"2021-09-28T03:25:27.916324Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = games['gameDate'].value_counts().reset_index()\n\ncheck.columns = [\n    'date', \n    'games'\n]\nprint(check)\n\ncheck = check.sort_values('games')\n\nfig = px.bar(check,x='games',y='date',orientation='h',title = 'Number of games for every date',height = 900,width=800)\n\nfig.show()\n\n\n","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:27.919021Z","iopub.execute_input":"2021-09-28T03:25:27.919359Z","iopub.status.idle":"2021-09-28T03:25:28.927383Z","shell.execute_reply.started":"2021-09-28T03:25:27.919316Z","shell.execute_reply":"2021-09-28T03:25:28.926751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = games['gameTimeEastern'].value_counts().reset_index()\n\ncheck.columns = [\n    'time', \n    'games'\n]\nprint(check)\n\ncheck = check.sort_values('games')\n\nfig = px.bar(check,x='games',y='time',orientation='h',title = 'Number of games for every time',height = 400,width=800)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:28.928424Z","iopub.execute_input":"2021-09-28T03:25:28.928851Z","iopub.status.idle":"2021-09-28T03:25:28.989095Z","shell.execute_reply.started":"2021-09-28T03:25:28.928811Z","shell.execute_reply":"2021-09-28T03:25:28.988223Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = games['visitorTeamAbbr'].value_counts().reset_index()\n\ncheck.columns = [\n    'team', \n    'games'\n]\nprint(check)\n\ncheck = check.sort_values('games')\n\nfig = px.bar(check,x='games',y='team',orientation='h',title = 'Number of games for every team(Away)',height = 800,width=800)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:28.9904Z","iopub.execute_input":"2021-09-28T03:25:28.990653Z","iopub.status.idle":"2021-09-28T03:25:29.05184Z","shell.execute_reply.started":"2021-09-28T03:25:28.990625Z","shell.execute_reply":"2021-09-28T03:25:29.050992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = games['homeTeamAbbr'].value_counts().reset_index()\n\ncheck.columns = [\n    'team', \n    'games'\n]\n\ncheck = check.sort_values('games')\n\nfig = px.bar(\n    check, \n    y='team', \n    x=\"games\", \n    orientation='h', \n    title='Number of games for every team(home)', \n    height=700, \n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.053127Z","iopub.execute_input":"2021-09-28T03:25:29.054022Z","iopub.status.idle":"2021-09-28T03:25:29.113835Z","shell.execute_reply.started":"2021-09-28T03:25:29.053978Z","shell.execute_reply":"2021-09-28T03:25:29.112962Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = games['week'].value_counts().reset_index()\n\ncheck.columns = [\n    'week', \n    'games'\n]\n\ncheck = check.sort_values('games')\ncheck['week'] = check['week'].astype(str) + '-'\n\nfig = px.bar(\n    check, \n    y='week', \n    x=\"games\", \n    orientation='h', \n    title='Number of games for every week', \n    height=500, \n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.115174Z","iopub.execute_input":"2021-09-28T03:25:29.116056Z","iopub.status.idle":"2021-09-28T03:25:29.1765Z","shell.execute_reply.started":"2021-09-28T03:25:29.116011Z","shell.execute_reply":"2021-09-28T03:25:29.175496Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<a id=\"2\"></a>\n<h2 style='background:transparent; border:0; color:black'><center>2. Player Data<center><h2>","metadata":{"execution":{"iopub.status.busy":"2021-09-25T03:01:40.874419Z","iopub.execute_input":"2021-09-25T03:01:40.874749Z","iopub.status.idle":"2021-09-25T03:01:40.880978Z","shell.execute_reply.started":"2021-09-25T03:01:40.874689Z","shell.execute_reply":"2021-09-25T03:01:40.879621Z"}}},{"cell_type":"markdown","source":"### **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* **nflId:** Player identification number, unique across players (numeric)\n\n* **height:** Player height (text)\n\n* **weight:** Player weight (numeric)\n\n* **birthDate:** Date of birth (YYYY-MM-DD)\n\n* **collegeName:** Player college (text)\n\n* **position:** Player position (text)\n\n* **displayName:** Player name (text)","metadata":{}},{"cell_type":"code","source":"players = pd.read_csv('../input/nfl-big-data-bowl-2022/players.csv')\nplayers","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.180229Z","iopub.execute_input":"2021-09-28T03:25:29.180632Z","iopub.status.idle":"2021-09-28T03:25:29.217213Z","shell.execute_reply.started":"2021-09-28T03:25:29.180602Z","shell.execute_reply":"2021-09-28T03:25:29.216483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(players.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.21851Z","iopub.execute_input":"2021-09-28T03:25:29.218716Z","iopub.status.idle":"2021-09-28T03:25:29.22579Z","shell.execute_reply.started":"2021-09-28T03:25:29.218693Z","shell.execute_reply":"2021-09-28T03:25:29.224797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.22723Z","iopub.execute_input":"2021-09-28T03:25:29.227896Z","iopub.status.idle":"2021-09-28T03:25:29.249542Z","shell.execute_reply.started":"2021-09-28T03:25:29.227863Z","shell.execute_reply":"2021-09-28T03:25:29.248832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.style.use('seaborn')\n\ncolor = plt.cm.flag(np.linspace(0,2,4))\nplayers['Position'].value_counts().plot.bar(color=color,figsize=(16,12))\n\nplt.title(\"Number of positions of players\")\nplt.xlabel('position')\nplt.ylabel('total count')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.251365Z","iopub.execute_input":"2021-09-28T03:25:29.251871Z","iopub.status.idle":"2021-09-28T03:25:29.59992Z","shell.execute_reply.started":"2021-09-28T03:25:29.251835Z","shell.execute_reply":"2021-09-28T03:25:29.599088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr = players.corr()\nfig, ax = plt.subplots(figsize=(12,8))\nsns.heatmap(corr)","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.601247Z","iopub.execute_input":"2021-09-28T03:25:29.601453Z","iopub.status.idle":"2021-09-28T03:25:29.84021Z","shell.execute_reply.started":"2021-09-28T03:25:29.60143Z","shell.execute_reply":"2021-09-28T03:25:29.839342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"converting all heights into feet.","metadata":{}},{"cell_type":"code","source":"check = players['height'].str.split('-',expand=True)\n\ncheck.columns = [\n    'first', \n    'second'\n]\n\ncheck.loc[(check['second'].notnull()), 'first'] = check[check['second'].notnull()]['first'].astype(np.int16) * 12 + check[check['second'].notnull()]['second'].astype(np.int16)\nplayers['height'] = check['first']\nplayers['height'] = players['height'].astype(np.float32)\nplayers['height'] /= 12\n\nplayers","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.841574Z","iopub.execute_input":"2021-09-28T03:25:29.841896Z","iopub.status.idle":"2021-09-28T03:25:29.875835Z","shell.execute_reply.started":"2021-09-28T03:25:29.841854Z","shell.execute_reply":"2021-09-28T03:25:29.87495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = make_subplots(rows=1, cols=2)\ntraces = [\n    go.Histogram(\n        x=players[col[0]], \n        nbinsx=col[1], \n        name=col[0]\n    ) for col in [('height', 20), ('weight', 50)]\n]\n\nfor i in range(len(traces)):\n    fig.append_trace(\n        traces[i], \n        (i // 2) + 1, \n        (i % 2) + 1\n    )\n\nfig.update_layout(\n    title_text='Height & weight distributions',\n    height=400,\n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.876995Z","iopub.execute_input":"2021-09-28T03:25:29.877316Z","iopub.status.idle":"2021-09-28T03:25:29.918892Z","shell.execute_reply.started":"2021-09-28T03:25:29.877287Z","shell.execute_reply":"2021-09-28T03:25:29.918359Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = players['collegeName'].value_counts().reset_index()\n\ncheck.columns = [\n    'college', \n    'players'\n]\n\nprint(check)\n\ncheck = check.sort_values('players').tail(50)\n\n\nfig = px.bar(\n    check, \n    y='college', \n    x=\"players\", \n    orientation='h', \n    title='Top 50 colleges by number of player', \n    height=900, \n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.920082Z","iopub.execute_input":"2021-09-28T03:25:29.920558Z","iopub.status.idle":"2021-09-28T03:25:29.980805Z","shell.execute_reply.started":"2021-09-28T03:25:29.920527Z","shell.execute_reply":"2021-09-28T03:25:29.979965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Players positions abbreviation\n\n* WR: Wide Receiver;\n* CB: Cornerback;\n* RB: Running Back;\n* TE: Tight End;\n* OLB: Outside Linebacker;\n* QB: Quarterback;\n* FS: Free Safety;\n* LB: Linebacker;\n* SS: Strong Safety;\n* ILB: Inside Linebacker;\n* DE: Defensive End;\n* DB: Defensive Back;\n* MLB: Middle Linebacker;\n* DT: Defensive Tackle;\n* FB: Fullback;\n* P: Punter;\n* LS: Long snapper;\n* S: Safety; \n* K: Kicker;\n* HB: Running back;\n* NT: Nose Tackle","metadata":{}},{"cell_type":"markdown","source":"<a id=\"3\"></a>\n<h2 style='background:transparent; border:0; color:black'><center>3. Play Data<center><h2>","metadata":{}},{"cell_type":"markdown","source":"### **Play data:** The plays.csv file contains play-level information from each game. The key variables are gameId and playId\n\n* **gameId:** Game identifier, unique (numeric)\n\n* **playId:** Play identifier, not unique across games (numeric)\n\n* **playDescription:** Description of play (text)\n\n* **quarter:** Game quarter (numeric)\n\n* **down:** Down (numeric)\n\n* **yardsToGo:** Distance needed for a first down (numeric)\n\n* **possessionTeam:** Team on offense (text)\n\n* **playType:** Outcome of dropback: sack or pass (text)\n\n* **yardlineSide:** 3-letter team code corresponding to line-of-scrimmage (text)\n\n* **yardlineNumber:** Yard line at line-of-scrimmage (numeric)\n\n* **offenseFormation:** Formation used by possession team (text)\n\n* **personnelO:** Personnel used by offensive team (text)\n\n* **defendersInTheBox:** Number of defenders in close proximity to line-of-scrimmage (numeric)\n\n* **numberOfPassRushers:** Number of pass rushers (numeric)\n\n* **personnelD:** Personnel used by defensive team (text)\n\n* **typeDropback:** Dropback categorization of quarterback (text)\n\n* **preSnapHomeScore:** Home score prior to the play (numeric)\n\n* **preSnapVisitorScore:** Visiting team score prior to the play (numeric)\n\n* **gameClock:** Time on clock of play (MM:SS)\n\n* **absoluteYardlineNumber:** Distance from end zone for possession team (numeric)\n\n* **penaltyCodes:** NFL categorization of the penalties that ocurred on the play. For purposes of this contest, the most important penalties are Defensive Pass Interference (DPI), Offensive Pass Interference (OPI), Illegal Contact (ICT), and Defensive Holding (DH). Multiple penalties on a play are separated by a ; (text)\n\n* **penaltyJerseyNumber:** Jersey number and team code of the player commiting each penalty. Multiple penalties on a play are separated by a ; (text)\n\n* **passResult:** Outcome of the passing play (C: Complete pass, I: Incomplete pass, S: Quarterback sack, IN: Intercepted pass, text)\n\n* **offensePlayResult:** Yards gained by the offense, excluding penalty yardage (numeric)\n\n* **playResult:** Net yards gained by the offense, including penalty yardage (numeric)\n\n* **epa:** Expected points added on the play, relative to the offensive team. Expected points is a metric that estimates the average of every next scoring outcome given the play's down, distance, yardline, and time remaining (numeric)\n\n* **isDefensivePI:** An indicator variable for whether or not a DPI penalty ocurred on a given play (TRUE/FALSE)","metadata":{}},{"cell_type":"code","source":"plays = pd.read_csv('../input/nfl-big-data-bowl-2022/plays.csv')\n\nplays","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:29.982574Z","iopub.execute_input":"2021-09-28T03:25:29.982902Z","iopub.status.idle":"2021-09-28T03:25:30.14964Z","shell.execute_reply.started":"2021-09-28T03:25:29.982859Z","shell.execute_reply":"2021-09-28T03:25:30.148624Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(plays.isnull().sum())","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:30.151005Z","iopub.execute_input":"2021-09-28T03:25:30.151264Z","iopub.status.idle":"2021-09-28T03:25:30.171014Z","shell.execute_reply.started":"2021-09-28T03:25:30.151236Z","shell.execute_reply":"2021-09-28T03:25:30.169911Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plays.info()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:30.17294Z","iopub.execute_input":"2021-09-28T03:25:30.173188Z","iopub.status.idle":"2021-09-28T03:25:30.201027Z","shell.execute_reply.started":"2021-09-28T03:25:30.173156Z","shell.execute_reply":"2021-09-28T03:25:30.200234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['quarter'].value_counts().reset_index()\n\ncheck.columns = [\n        'quarter',\n        'plays'\n]\n\ncheck = check.sort_values('plays')\n\nfig = px.pie(\n    check,\n    names = 'quarter',\n    values = 'plays',\n    title = 'number of players per quarter',\n    height = 500,\n    width = 800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:30.202312Z","iopub.execute_input":"2021-09-28T03:25:30.202528Z","iopub.status.idle":"2021-09-28T03:25:30.26758Z","shell.execute_reply.started":"2021-09-28T03:25:30.202504Z","shell.execute_reply":"2021-09-28T03:25:30.266688Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr = plays.corr()\nfig, ax = plt.subplots(figsize=(12,8))\nsns.heatmap(corr)","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:30.269312Z","iopub.execute_input":"2021-09-28T03:25:30.269694Z","iopub.status.idle":"2021-09-28T03:25:30.882637Z","shell.execute_reply.started":"2021-09-28T03:25:30.269653Z","shell.execute_reply":"2021-09-28T03:25:30.881644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"ploting the missing values","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(8,6))\nmissing = plays.isnull().sum()\nmissing = missing[missing>0]\nmissing.sort_values(inplace=True)\nmissing.plot.bar(ax=ax)","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:30.884199Z","iopub.execute_input":"2021-09-28T03:25:30.884586Z","iopub.status.idle":"2021-09-28T03:25:31.167872Z","shell.execute_reply.started":"2021-09-28T03:25:30.884542Z","shell.execute_reply":"2021-09-28T03:25:31.167169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['down'].value_counts().reset_index()\n\ncheck.columns = [\n        'down',\n        'plays'\n]\n\ncheck = check.sort_values('plays')\n\nfig = px.pie(\n    check,\n    names = 'down',\n    values = 'plays',\n    title = 'number of players per down',\n    height = 500,\n    width = 800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.169018Z","iopub.execute_input":"2021-09-28T03:25:31.169723Z","iopub.status.idle":"2021-09-28T03:25:31.217985Z","shell.execute_reply.started":"2021-09-28T03:25:31.169685Z","shell.execute_reply":"2021-09-28T03:25:31.217395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['yardsToGo'].value_counts().reset_index()\n\ncheck.columns = [\n    'yardsToGo', \n    'plays'\n]\ncheck['yardsToGo'] = check['yardsToGo'].astype(str) + '-'\ncheck = check.sort_values('plays')\n\n\nfig = px.bar(\n    check, \n    y='yardsToGo', \n    x=\"plays\", \n    orientation='h', \n    title='Number of plays for every yardsToGo category', \n    height=800, \n    width=800\n)\n\nfig.show()\n","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.219045Z","iopub.execute_input":"2021-09-28T03:25:31.219719Z","iopub.status.idle":"2021-09-28T03:25:31.279616Z","shell.execute_reply.started":"2021-09-28T03:25:31.219684Z","shell.execute_reply":"2021-09-28T03:25:31.278863Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['possessionTeam'].value_counts().reset_index()\n\ncheck.columns = [\n    'possessionTeam', \n    'plays'\n]\ncheck['possessionTeam'] = check['possessionTeam'].astype(str) + '-'\ncheck = check.sort_values('plays')\n\n\nfig = px.bar(\n    check, \n    y='possessionTeam', \n    x=\"plays\", \n    orientation='h', \n    title='Number of plays for every Team', \n    height=800, \n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.28099Z","iopub.execute_input":"2021-09-28T03:25:31.281606Z","iopub.status.idle":"2021-09-28T03:25:31.345238Z","shell.execute_reply.started":"2021-09-28T03:25:31.281566Z","shell.execute_reply":"2021-09-28T03:25:31.344576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['yardlineSide'].value_counts().reset_index()\n\ncheck.columns = [\n    'yardlineSide', \n    'plays'\n]\n\ncheck = check.sort_values('plays')\n\nfig = px.bar(\n    check, \n    y='yardlineSide', \n    x=\"plays\", \n    orientation='h', \n    title='Number of plays for every team yard side',\n    height=800,\n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.346347Z","iopub.execute_input":"2021-09-28T03:25:31.34696Z","iopub.status.idle":"2021-09-28T03:25:31.406442Z","shell.execute_reply.started":"2021-09-28T03:25:31.346918Z","shell.execute_reply":"2021-09-28T03:25:31.405806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['yardlineNumber'].value_counts().reset_index()\n\ncheck.columns = [\n    'yardline', \n    'plays'\n]\n\ncheck = check.sort_values('plays')\n\nfig = px.bar(\n    check, \n    y='plays', \n    x=\"yardline\", \n    orientation='v', \n    title='Number of plays for every team yardline',\n    height=500,\n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.409329Z","iopub.execute_input":"2021-09-28T03:25:31.41006Z","iopub.status.idle":"2021-09-28T03:25:31.473982Z","shell.execute_reply.started":"2021-09-28T03:25:31.410023Z","shell.execute_reply":"2021-09-28T03:25:31.473046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ncheck = plays['absoluteYardlineNumber'].value_counts().reset_index()\n\ncheck.columns = [\n    'absyardline', \n    'plays'\n]\n\ncheck = check.sort_values('plays')\n\nfig = px.bar(\n    check, \n    y='plays', \n    x=\"absyardline\", \n    orientation='v', \n    title='Number of plays for every team on absyardline',\n    height=500,\n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.475187Z","iopub.execute_input":"2021-09-28T03:25:31.475441Z","iopub.status.idle":"2021-09-28T03:25:31.537112Z","shell.execute_reply.started":"2021-09-28T03:25:31.475411Z","shell.execute_reply":"2021-09-28T03:25:31.536163Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Or we can also make a histogram for the above chart.","metadata":{}},{"cell_type":"code","source":"fig = px.histogram(\n    plays,\n    x='absoluteYardlineNumber',\n    width=800,\n    height=500,\n    nbins=50,\n    title = 'Absolute yardline number distribution')\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.538211Z","iopub.execute_input":"2021-09-28T03:25:31.538655Z","iopub.status.idle":"2021-09-28T03:25:31.679495Z","shell.execute_reply.started":"2021-09-28T03:25:31.538624Z","shell.execute_reply":"2021-09-28T03:25:31.678424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = plays['passResult'].value_counts().reset_index()\n\ncheck.columns = [\n    'passResult', \n    'plays'\n]\n\ncheck = check.sort_values('plays')\n\nfig = px.pie(\n    check, \n    names='passResult', \n    values=\"plays\",  \n    title='Number of plays for every pass result',\n    height=500,\n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.680746Z","iopub.execute_input":"2021-09-28T03:25:31.681006Z","iopub.status.idle":"2021-09-28T03:25:31.73412Z","shell.execute_reply.started":"2021-09-28T03:25:31.680977Z","shell.execute_reply":"2021-09-28T03:25:31.733107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.histogram(\n    plays, \n    x=\"playResult\",\n    width=800,\n    height=500,\n    nbins=50,\n    title='Play result distribution'\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.735592Z","iopub.execute_input":"2021-09-28T03:25:31.735934Z","iopub.status.idle":"2021-09-28T03:25:31.84335Z","shell.execute_reply.started":"2021-09-28T03:25:31.735892Z","shell.execute_reply":"2021-09-28T03:25:31.842469Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.histogram(\n    plays, \n    x=\"preSnapVisitorScore\",\n    width=800,\n    height=500,\n    nbins=50,\n    title='Pre Snap Visitor Score distribution'\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.845392Z","iopub.execute_input":"2021-09-28T03:25:31.845761Z","iopub.status.idle":"2021-09-28T03:25:31.955079Z","shell.execute_reply.started":"2021-09-28T03:25:31.845717Z","shell.execute_reply":"2021-09-28T03:25:31.954078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.histogram(\n    plays, \n    x=\"preSnapHomeScore\",\n    width=800,\n    height=500,\n    nbins=50,\n    title='Pre Snap Home Score distribution'\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2021-09-28T03:25:31.95653Z","iopub.execute_input":"2021-09-28T03:25:31.956756Z","iopub.status.idle":"2021-09-28T03:25:32.203823Z","shell.execute_reply.started":"2021-09-28T03:25:31.95673Z","shell.execute_reply":"2021-09-28T03:25:32.202969Z"},"trusted":true},"execution_count":null,"outputs":[]}]}