{"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":"2022-01-11T07:27:41.961703Z","iopub.execute_input":"2022-01-11T07:27:41.962334Z","iopub.status.idle":"2022-01-11T07:27:41.994178Z","shell.execute_reply.started":"2022-01-11T07:27:41.96222Z","shell.execute_reply":"2022-01-11T07:27:41.993481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)import seaborn as sns\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nfrom datetime import datetime, date\n\nimport plotly.express as px\nfrom plotly.subplots import make_subplots\nimport plotly.graph_objs as go","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:41.996126Z","iopub.execute_input":"2022-01-11T07:27:41.99662Z","iopub.status.idle":"2022-01-11T07:27:44.268222Z","shell.execute_reply.started":"2022-01-11T07:27:41.996575Z","shell.execute_reply":"2022-01-11T07:27:44.267159Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/games.csv')\ndf.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:44.269481Z","iopub.execute_input":"2022-01-11T07:27:44.269703Z","iopub.status.idle":"2022-01-11T07:27:44.304931Z","shell.execute_reply.started":"2022-01-11T07:27:44.269676Z","shell.execute_reply":"2022-01-11T07:27:44.30436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dict={}\nfor i in list(df.columns):\n    dict[i]=df[i].value_counts().shape[0]\npd.DataFrame(dict,index=['unique count'])","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:44.306746Z","iopub.execute_input":"2022-01-11T07:27:44.30714Z","iopub.status.idle":"2022-01-11T07:27:44.331164Z","shell.execute_reply.started":"2022-01-11T07:27:44.307095Z","shell.execute_reply":"2022-01-11T07:27:44.330235Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def resumetable(df):\n    print(f'Shape : {df.shape}')\n    summary = pd.DataFrame(df.dtypes, columns=['Data Type'])\n    summary = summary.reset_index()\n    summary = summary.rename(columns={'index': 'Feature'})\n    summary['Num of null'] = df.isnull().sum().values\n    summary['Num of unique'] = df.nunique().values\n    summary['First value'] = df.loc[0].values\n    summary['Second value'] = df.loc[1].values\n    summary['Third value'] = df.loc[2].values\n    return summary\nresumetable(df)\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:44.332497Z","iopub.execute_input":"2022-01-11T07:27:44.332732Z","iopub.status.idle":"2022-01-11T07:27:44.36028Z","shell.execute_reply.started":"2022-01-11T07:27:44.332697Z","shell.execute_reply":"2022-01-11T07:27:44.359376Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['gameYear']=0\ndf['gameMonth']=0\ndf.dropna(subset=['gameDate'],inplace=True)\nfor idx,row in df.iterrows():\n    if len(row['gameDate'].split('/'))==3:\n        df.loc[idx,'gameYear']=row['gameDate'].split('/')[2]\n        df.loc[idx,'gameMonth']=row['gameDate'].split('/')[0]\n    elif len(row['gameDate'].split('-'))==3:\n        df.loc[idx,'gameYear']=row['gameDate'].split('-')[0]\n        df.loc[idx,'gameMonth']=row['gameDate'].split('-')[1]","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:44.361466Z","iopub.execute_input":"2022-01-11T07:27:44.361672Z","iopub.status.idle":"2022-01-11T07:27:44.764321Z","shell.execute_reply.started":"2022-01-11T07:27:44.361647Z","shell.execute_reply":"2022-01-11T07:27:44.763435Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"homeTeamAbbr\", data=df, palette=\"Set2\", order=df['homeTeamAbbr'].value_counts().index[0:15])\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:44.765556Z","iopub.execute_input":"2022-01-11T07:27:44.765778Z","iopub.status.idle":"2022-01-11T07:27:45.224811Z","shell.execute_reply.started":"2022-01-11T07:27:44.765751Z","shell.execute_reply":"2022-01-11T07:27:45.223951Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"gameTimeEastern\", data=df, palette=\"Set2\", order=df['gameTimeEastern'].value_counts().index[0:16])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:45.225979Z","iopub.execute_input":"2022-01-11T07:27:45.226178Z","iopub.status.idle":"2022-01-11T07:27:45.783575Z","shell.execute_reply.started":"2022-01-11T07:27:45.226151Z","shell.execute_reply":"2022-01-11T07:27:45.782531Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"gameTimeEastern\", data=df, palette=\"Set2\", order=df['gameTimeEastern'].value_counts().index[0:16])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:45.784975Z","iopub.execute_input":"2022-01-11T07:27:45.78521Z","iopub.status.idle":"2022-01-11T07:27:46.221657Z","shell.execute_reply.started":"2022-01-11T07:27:45.785181Z","shell.execute_reply":"2022-01-11T07:27:46.220678Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"visitorTeamAbbr\", data=df, palette=\"Set2\", order=df['visitorTeamAbbr'].value_counts().index[0:16])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:46.224797Z","iopub.execute_input":"2022-01-11T07:27:46.225065Z","iopub.status.idle":"2022-01-11T07:27:46.644917Z","shell.execute_reply.started":"2022-01-11T07:27:46.225031Z","shell.execute_reply":"2022-01-11T07:27:46.644102Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"gameDate\", data=df, palette=\"Set2\", order=df['gameDate'].value_counts().index[0:20])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:46.646342Z","iopub.execute_input":"2022-01-11T07:27:46.646676Z","iopub.status.idle":"2022-01-11T07:27:47.236187Z","shell.execute_reply.started":"2022-01-11T07:27:46.646643Z","shell.execute_reply":"2022-01-11T07:27:47.235045Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"check = df['gameDate'].value_counts().reset_index()\n\ncheck.columns = [\n    'date', \n    'games'\n]\n\ncheck = check.sort_values('games')\n\nfig = px.bar(\n    check, \n    y='date', \n    x=\"games\", \n    orientation='h', \n    title='Number of games for every date', \n    height=900, \n    width=800\n)\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:47.237522Z","iopub.execute_input":"2022-01-11T07:27:47.237803Z","iopub.status.idle":"2022-01-11T07:27:48.339388Z","shell.execute_reply.started":"2022-01-11T07:27:47.237772Z","shell.execute_reply":"2022-01-11T07:27:48.338561Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"week\", data=df, palette=\"Set2\", order=df['week'].value_counts().index[0:17])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:48.340614Z","iopub.execute_input":"2022-01-11T07:27:48.340904Z","iopub.status.idle":"2022-01-11T07:27:48.75473Z","shell.execute_reply.started":"2022-01-11T07:27:48.340873Z","shell.execute_reply":"2022-01-11T07:27:48.75377Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, axes = plt.subplots(1, 1, figsize=(20, 15), sharey=True)\nsns.countplot(ax=axes,x=df['gameTimeEastern'],data=df,hue='season',palette = 'PuBuGn_d')\naxes.set_title('gameTimeEastern segregated by season'  , fontsize = 20)\naxes.set_xticklabels(axes.get_xticklabels(), rotation=30)\nfor p in axes.patches:\n    height = p.get_height()\n    axes.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:48.756253Z","iopub.execute_input":"2022-01-11T07:27:48.756613Z","iopub.status.idle":"2022-01-11T07:27:49.586515Z","shell.execute_reply.started":"2022-01-11T07:27:48.75657Z","shell.execute_reply":"2022-01-11T07:27:49.585731Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:49.587529Z","iopub.execute_input":"2022-01-11T07:27:49.58773Z","iopub.status.idle":"2022-01-11T07:27:49.601474Z","shell.execute_reply.started":"2022-01-11T07:27:49.587704Z","shell.execute_reply":"2022-01-11T07:27:49.600873Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"gameMonth\", data=df, palette=\"Set2\", order=df['gameMonth'].value_counts().index[0:5])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:49.602703Z","iopub.execute_input":"2022-01-11T07:27:49.602918Z","iopub.status.idle":"2022-01-11T07:27:49.857017Z","shell.execute_reply.started":"2022-01-11T07:27:49.60289Z","shell.execute_reply":"2022-01-11T07:27:49.856148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"gameYear\", data=df, palette=\"Set2\", order=df['gameYear'].value_counts().index[0:5])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")\n","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:49.858129Z","iopub.execute_input":"2022-01-11T07:27:49.858693Z","iopub.status.idle":"2022-01-11T07:27:50.099261Z","shell.execute_reply.started":"2022-01-11T07:27:49.858639Z","shell.execute_reply":"2022-01-11T07:27:50.098713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_player=pd.read_csv('/kaggle/input/nfl-big-data-bowl-2022/players.csv')\ndf_player.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:50.100178Z","iopub.execute_input":"2022-01-11T07:27:50.10077Z","iopub.status.idle":"2022-01-11T07:27:50.133431Z","shell.execute_reply.started":"2022-01-11T07:27:50.100734Z","shell.execute_reply":"2022-01-11T07:27:50.132635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_player[\"birthYear\"] = 0\ndf_player[\"birthMonth\"] = 0\ndf_player.dropna(subset=[\"birthDate\"], inplace=True)\nfor idx, row in df_player.iterrows():\n    if len(row['birthDate'].split('/')) == 3: # 05/17/1994 \n        df_player.loc[idx, 'birthYear'] = row['birthDate'].split('/')[2]\n        df_player.loc[idx, 'birthMonth'] = row['birthDate'].split('/')[0]\n        \n    elif len(row['birthDate'].split('-')) == 3: # 1995-05-05\n        df_player.loc[idx, 'birthYear'] = row['birthDate'].split('-')[0]\n        df_player.loc[idx, 'birthMonth'] = row['birthDate'].split('-')[1]","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:50.134517Z","iopub.execute_input":"2022-01-11T07:27:50.134738Z","iopub.status.idle":"2022-01-11T07:27:51.714215Z","shell.execute_reply.started":"2022-01-11T07:27:50.13471Z","shell.execute_reply":"2022-01-11T07:27:51.713505Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_player.head(5)","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:51.715233Z","iopub.execute_input":"2022-01-11T07:27:51.715786Z","iopub.status.idle":"2022-01-11T07:27:51.729576Z","shell.execute_reply.started":"2022-01-11T07:27:51.715749Z","shell.execute_reply":"2022-01-11T07:27:51.728834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dict={}\nfor i in list(df_player.columns):\n    dict[i]=df_player[i].value_counts().shape[0]\npd.DataFrame(dict,index=['unique count'])","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:51.730715Z","iopub.execute_input":"2022-01-11T07:27:51.730949Z","iopub.status.idle":"2022-01-11T07:27:51.757477Z","shell.execute_reply.started":"2022-01-11T07:27:51.73092Z","shell.execute_reply":"2022-01-11T07:27:51.756656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"birthMonth\", data=df_player, palette=\"Set2\", order=df_player['birthMonth'].value_counts().index[0:12])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:51.75876Z","iopub.execute_input":"2022-01-11T07:27:51.759466Z","iopub.status.idle":"2022-01-11T07:27:52.116141Z","shell.execute_reply.started":"2022-01-11T07:27:51.759425Z","shell.execute_reply":"2022-01-11T07:27:52.115352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"birthYear\", data=df_player, palette=\"Set2\", order=df_player['birthYear'].value_counts().index[0:12])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:52.117813Z","iopub.execute_input":"2022-01-11T07:27:52.118392Z","iopub.status.idle":"2022-01-11T07:27:52.64815Z","shell.execute_reply.started":"2022-01-11T07:27:52.118345Z","shell.execute_reply":"2022-01-11T07:27:52.647312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"Position\", data=df_player, palette=\"Set2\", order=df_player['Position'].value_counts().index[0:20])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:52.649685Z","iopub.execute_input":"2022-01-11T07:27:52.65015Z","iopub.status.idle":"2022-01-11T07:27:53.146992Z","shell.execute_reply.started":"2022-01-11T07:27:52.650105Z","shell.execute_reply":"2022-01-11T07:27:53.146374Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"collegeName\", data=df_player, palette=\"Set2\", order=df_player['collegeName'].value_counts().index[0:30])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:53.148652Z","iopub.execute_input":"2022-01-11T07:27:53.149231Z","iopub.status.idle":"2022-01-11T07:27:53.887218Z","shell.execute_reply.started":"2022-01-11T07:27:53.149185Z","shell.execute_reply":"2022-01-11T07:27:53.886349Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df_player['weight']\nplt.figure(figsize=(18,10))\nax = sns.distplot(x)\nax.set_xlabel(xlabel = \"weight\", fontsize = 16)\nax.set_title(label = 'Distribution of weight', fontsize = 20)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:53.888748Z","iopub.execute_input":"2022-01-11T07:27:53.889263Z","iopub.status.idle":"2022-01-11T07:27:54.250998Z","shell.execute_reply.started":"2022-01-11T07:27:53.889217Z","shell.execute_reply":"2022-01-11T07:27:54.250169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"players_heights = df_player[\"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\ndf_player[\"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\ndf_player[\"weight\"] = round(df_player.weight * 0.453592, 2)\n\ndf_player","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:54.25247Z","iopub.execute_input":"2022-01-11T07:27:54.25293Z","iopub.status.idle":"2022-01-11T07:27:54.284603Z","shell.execute_reply.started":"2022-01-11T07:27:54.252887Z","shell.execute_reply":"2022-01-11T07:27:54.283862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df_player['height']\nplt.figure(figsize=(18,10))\nax = sns.distplot(x)\nax.set_xlabel(xlabel = \"height\", fontsize = 16)\nax.set_title(label = 'Distribution of height', fontsize = 20)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:54.288018Z","iopub.execute_input":"2022-01-11T07:27:54.28833Z","iopub.status.idle":"2022-01-11T07:27:54.631923Z","shell.execute_reply.started":"2022-01-11T07:27:54.288287Z","shell.execute_reply":"2022-01-11T07:27:54.631001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(12,10))\nsns.set(style=\"darkgrid\")\nax = sns.countplot(x=\"displayName\", data=df_player, palette=\"Set2\", order=df_player['displayName'].value_counts().index[0:30])\nplt.xticks(rotation = 70)\nfor p in ax.patches:\n    height = p.get_height()\n    ax.text(p.get_x()+p.get_width()/2., height + 0.1,height ,ha=\"center\")","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:54.633084Z","iopub.execute_input":"2022-01-11T07:27:54.633306Z","iopub.status.idle":"2022-01-11T07:27:55.365754Z","shell.execute_reply.started":"2022-01-11T07:27:54.633267Z","shell.execute_reply":"2022-01-11T07:27:55.364908Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(10, 6), dpi=100)\nsns.regplot(x=df_player.weight, y=df_player.height, line_kws={\"color\": \"red\"})\nplt.title(\"Player Weight(Kg) vs Player Height(cm)\");","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:55.366839Z","iopub.execute_input":"2022-01-11T07:27:55.36705Z","iopub.status.idle":"2022-01-11T07:27:55.941165Z","shell.execute_reply.started":"2022-01-11T07:27:55.367023Z","shell.execute_reply":"2022-01-11T07:27:55.940212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from datetime import date\n \ndef age(birthdate):\n    today = date.today()\n    age = today.year - birthdate.year - ((today.month, today.day) < (birthdate.month, birthdate.day))\n    return age","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:55.942908Z","iopub.execute_input":"2022-01-11T07:27:55.943288Z","iopub.status.idle":"2022-01-11T07:27:55.951643Z","shell.execute_reply.started":"2022-01-11T07:27:55.943233Z","shell.execute_reply":"2022-01-11T07:27:55.950802Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_player['birthDate'] = pd.to_datetime(df_player['birthDate'])\n\ntoday = datetime.today()\ndf_player['age'] = df_player['birthDate'].apply(lambda x: today.year - x.year - ((today.month, today.day) < (x.month, x.day)))\n\nbins= [21.0,26.0,31.0,36.0,41.0,46.0,51.0]\nlabels = ['21-25','26-30','31-35','36-40','41-45','46-50']\ndf_player['agegroup'] = pd.cut(df_player['age'], bins=bins, labels=labels, right=False)\ndf_player[:2]","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:55.953047Z","iopub.execute_input":"2022-01-11T07:27:55.953861Z","iopub.status.idle":"2022-01-11T07:27:56.013034Z","shell.execute_reply.started":"2022-01-11T07:27:55.953815Z","shell.execute_reply":"2022-01-11T07:27:56.012117Z"},"jupyter":{"source_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df_player['age']\nplt.figure(figsize=(18,10))\nax = sns.distplot(x)\nax.set_xlabel(xlabel = \"age\", fontsize = 16)\nax.set_title(label = 'Distribution of age', fontsize = 20)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-01-11T07:27:56.014458Z","iopub.execute_input":"2022-01-11T07:27:56.014769Z","iopub.status.idle":"2022-01-11T07:27:56.422796Z","shell.execute_reply.started":"2022-01-11T07:27:56.014725Z","shell.execute_reply":"2022-01-11T07:27:56.421832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}