{"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\nimport seaborn as sns","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-09-08T06:36:55.879723Z","iopub.execute_input":"2022-09-08T06:36:55.880158Z","iopub.status.idle":"2022-09-08T06:36:56.511234Z","shell.execute_reply.started":"2022-09-08T06:36:55.880125Z","shell.execute_reply":"2022-09-08T06:36:56.510384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let us have a look at start table to see what we can decipher about the horse - jokey relation","metadata":{}},{"cell_type":"code","source":"df1=pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_start_table.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:56.514875Z","iopub.execute_input":"2022-09-08T06:36:56.515846Z","iopub.status.idle":"2022-09-08T06:36:56.551675Z","shell.execute_reply.started":"2022-09-08T06:36:56.515804Z","shell.execute_reply":"2022-09-08T06:36:56.550527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:56.553269Z","iopub.execute_input":"2022-09-08T06:36:56.553736Z","iopub.status.idle":"2022-09-08T06:36:56.575431Z","shell.execute_reply.started":"2022-09-08T06:36:56.553688Z","shell.execute_reply":"2022-09-08T06:36:56.574498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1.head()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:56.577803Z","iopub.execute_input":"2022-09-08T06:36:56.578290Z","iopub.status.idle":"2022-09-08T06:36:56.594353Z","shell.execute_reply.started":"2022-09-08T06:36:56.578255Z","shell.execute_reply":"2022-09-08T06:36:56.593396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Let us see what unique values each of the columns have.","metadata":{}},{"cell_type":"code","source":"df1['track_id'].unique()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:56.595606Z","iopub.execute_input":"2022-09-08T06:36:56.595938Z","iopub.status.idle":"2022-09-08T06:36:56.611441Z","shell.execute_reply.started":"2022-09-08T06:36:56.595906Z","shell.execute_reply":"2022-09-08T06:36:56.610064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"So, there are three track ids-\nAQU,\nBEL and\nSAR","metadata":{}},{"cell_type":"code","source":"ax=sns.barplot(x=list(df1['track_id'].unique()),y=list(df1['track_id'].value_counts()))\nfor i in ax.containers:\n    ax.bar_label(i,)","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:56.613158Z","iopub.execute_input":"2022-09-08T06:36:56.613492Z","iopub.status.idle":"2022-09-08T06:36:56.858627Z","shell.execute_reply.started":"2022-09-08T06:36:56.613461Z","shell.execute_reply":"2022-09-08T06:36:56.857470Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the barchart above it is evident that we have more participation in Aqueduct than in Saratoga.The participation in Aqueduct is almost twice as much as that in Saratoga.","metadata":{}},{"cell_type":"code","source":"ax=sns.barplot(x=list(df1['track_id'].unique()),y=list(df1.groupby(['track_id'])['program_number'].nunique()))\nfor i in ax.containers:\n    ax.bar_label(i,)","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:56.860106Z","iopub.execute_input":"2022-09-08T06:36:56.860464Z","iopub.status.idle":"2022-09-08T06:36:57.080139Z","shell.execute_reply.started":"2022-09-08T06:36:56.860430Z","shell.execute_reply":"2022-09-08T06:36:57.079072Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the barchart above, it is clear that 18 horses participated each in Saratoga and Aqueduct where as Belmonte had highest number of horses participating at 20.In the barchart earlier we saw that Aqueduct had highest number of line items.So, it seems that Aqueduct held more races than other two tracks as the number of horses is less than that in Belmonte.","metadata":{}},{"cell_type":"code","source":"ax=sns.barplot(x=list(df1['track_id'].unique()),y=list(df1.groupby(['track_id'])['race_number'].nunique()))\nfor i in ax.containers:\n    ax.bar_label(i,)","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:57.081520Z","iopub.execute_input":"2022-09-08T06:36:57.081869Z","iopub.status.idle":"2022-09-08T06:36:57.286254Z","shell.execute_reply.started":"2022-09-08T06:36:57.081837Z","shell.execute_reply":"2022-09-08T06:36:57.285139Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"From the bar chart above it is evident that Belmonte and Saratoga had 13 races each and Aqueduct had 11 races on particular race days. Even though Aqueduct has highest number of rows in the data,it is not highest in terms of number of races on a race day and number of horses participating on a race day.So, this leads us to deduce that Aqueduct may have had highest number of race days.","metadata":{}},{"cell_type":"code","source":"ax=sns.barplot(x=list(df1['track_id'].unique()),y=list(df1.groupby(['track_id'])['race_date'].nunique()))\nfor i in ax.containers:\n    ax.bar_label(i,)","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:57.287772Z","iopub.execute_input":"2022-09-08T06:36:57.288747Z","iopub.status.idle":"2022-09-08T06:36:57.488684Z","shell.execute_reply.started":"2022-09-08T06:36:57.288697Z","shell.execute_reply":"2022-09-08T06:36:57.487527Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"As is evident from the bar chart above and also from our deductive logic, Aqueduct had the highest number of race days.","metadata":{}},{"cell_type":"code","source":"ax=sns.barplot(x=list(df1['track_id'].unique()),y=list(df1.groupby(['track_id'])['jockey'].nunique()))\nfor i in ax.containers:\n    ax.bar_label(i,)","metadata":{"execution":{"iopub.status.busy":"2022-09-08T06:36:57.491290Z","iopub.execute_input":"2022-09-08T06:36:57.491634Z","iopub.status.idle":"2022-09-08T06:36:57.700696Z","shell.execute_reply.started":"2022-09-08T06:36:57.491602Z","shell.execute_reply":"2022-09-08T06:36:57.699590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"In terms of jockey participation , Belmonte scores highest and Saratoga scores lowest. This may be because Saratoga has had fewer race days in 2019.","metadata":{}},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}