{"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":"This is a starter EDA notebook for this competition. After reading this notebook, you may have a look at my another notebook which calculates the distances taken by each horse between two consecutive trakus logs: [Big Data Derby: Distances between trakus indices](https://www.kaggle.com/code/ozoozo/big-data-derby-distances-between-trakus-indices/notebook).","metadata":{}},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>Reading Input Datafiles</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:50px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>Let's start with reading the input data:</div></b> ","metadata":{}},{"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)\n\nfrom matplotlib import pyplot as plt\nimport matplotlib.ticker as plticker\nimport seaborn as sns\nimport plotly.express as px\n\n\nsns.set_palette(\"hls\")\n\n","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:54:35.983950Z","iopub.execute_input":"2022-09-20T11:54:35.984767Z","iopub.status.idle":"2022-09-20T11:54:38.051810Z","shell.execute_reply.started":"2022-09-20T11:54:35.984653Z","shell.execute_reply":"2022-09-20T11:54:38.050875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:54:38.054177Z","iopub.execute_input":"2022-09-20T11:54:38.055035Z","iopub.status.idle":"2022-09-20T11:54:38.063020Z","shell.execute_reply.started":"2022-09-20T11:54:38.054986Z","shell.execute_reply":"2022-09-20T11:54:38.061804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center;font-style:italic; '>We have 4 tables: Tracking, start, race and the combined table of those three tables: 2019_complete. Let's read the 2019_complete table:</div></b> ","metadata":{}},{"cell_type":"code","source":"df_complete = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_2019_complete.csv\")\ndf_complete.columns = [\"track_id\",\"race_date\",\"race_number\",\"program_number\",\"trakus_index\",\"latitude\",\"longitude\",\"distance_id\",\"course_type\",\"track_condition\",\"run_up_distance\",\"race_type\",\"purse\",\"post_time\",\"weight_carried\",\"jockey\",\"odds\",\"position\"]\ndf_complete","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:54:38.064520Z","iopub.execute_input":"2022-09-20T11:54:38.066021Z","iopub.status.idle":"2022-09-20T11:54:56.289418Z","shell.execute_reply.started":"2022-09-20T11:54:38.065975Z","shell.execute_reply":"2022-09-20T11:54:56.288328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>We have 5228430 rows and 17 columns.</div></b> ","metadata":{}},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>Datatypes of columns</div></b> ","metadata":{}},{"cell_type":"code","source":"df_complete.dtypes","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:54:56.291658Z","iopub.execute_input":"2022-09-20T11:54:56.291992Z","iopub.status.idle":"2022-09-20T11:54:56.299710Z","shell.execute_reply.started":"2022-09-20T11:54:56.291961Z","shell.execute_reply":"2022-09-20T11:54:56.298912Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"track_id\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"sns.set_palette(\"hls\")\n\nfig, ax = plt.subplots()\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"track_id\")","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:54:56.300857Z","iopub.execute_input":"2022-09-20T11:54:56.301471Z","iopub.status.idle":"2022-09-20T11:55:01.982326Z","shell.execute_reply.started":"2022-09-20T11:54:56.301440Z","shell.execute_reply":"2022-09-20T11:55:01.981479Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"track_id\" column shows the three places that races took place at: AQU -Aqueduct, BEL - Belmont, SAR - Saratoga. Let's create different dataframes for each place:</div></b> ","metadata":{}},{"cell_type":"code","source":"df_aqu = df_complete.loc[df_complete[\"track_id\"]==\"AQU\",:]\ndf_bel = df_complete.loc[df_complete[\"track_id\"]==\"BEL\",:]\ndf_sar = df_complete.loc[df_complete[\"track_id\"]==\"SAR\",:]","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:01.983532Z","iopub.execute_input":"2022-09-20T11:55:01.984085Z","iopub.status.idle":"2022-09-20T11:55:03.774138Z","shell.execute_reply.started":"2022-09-20T11:55:01.984051Z","shell.execute_reply":"2022-09-20T11:55:03.773076Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"race_date\" column</div></b>","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>Let's change the data type of race_date to datetime:</div></b> ","metadata":{}},{"cell_type":"code","source":"df_complete[\"race_date\"] = pd.to_datetime(df_complete[\"race_date\"])","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:03.775503Z","iopub.execute_input":"2022-09-20T11:55:03.775918Z","iopub.status.idle":"2022-09-20T11:55:05.097934Z","shell.execute_reply.started":"2022-09-20T11:55:03.775887Z","shell.execute_reply":"2022-09-20T11:55:05.096724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig, ax = plt.subplots(figsize=(20,5))\n\nsns.histplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"race_date\")\nax.set_title(\"Entry counts\", fontsize=20)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:05.099388Z","iopub.execute_input":"2022-09-20T11:55:05.099746Z","iopub.status.idle":"2022-09-20T11:55:13.763654Z","shell.execute_reply.started":"2022-09-20T11:55:05.099715Z","shell.execute_reply":"2022-09-20T11:55:13.762515Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>It seems that, approximately, summer races take place at Saratoga, spring and fall races take place at Belmont, and winter races take place at Aqueduct.</div></b> ","metadata":{}},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"race_number\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"sns.set_palette(\"hls\")\n\nfig, ax = plt.subplots(figsize=(20,5))\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"race_number\")","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:13.764791Z","iopub.execute_input":"2022-09-20T11:55:13.765088Z","iopub.status.idle":"2022-09-20T11:55:16.986596Z","shell.execute_reply.started":"2022-09-20T11:55:13.765060Z","shell.execute_reply":"2022-09-20T11:55:16.985514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"race_number\"s lie between 1 and 13, so we can change the data type of it to int8:</div></b> ","metadata":{}},{"cell_type":"code","source":"df_complete[\"race_number\"] = df_complete[\"race_number\"].astype(\"int8\")","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:16.991618Z","iopub.execute_input":"2022-09-20T11:55:16.992080Z","iopub.status.idle":"2022-09-20T11:55:17.111566Z","shell.execute_reply.started":"2022-09-20T11:55:16.992044Z","shell.execute_reply":"2022-09-20T11:55:17.110590Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"program_number\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"program_number\"s are actually the horse numbers in that race.</div></b> ","metadata":{}},{"cell_type":"code","source":"print(\"Program numbers of all races:\",df_complete[\"program_number\"].unique())\nprint(\"Program numbers of AQU races:\",df_complete.loc[df_complete[\"track_id\"]==\"AQU\",\"program_number\"].unique())\nprint(\"Program numbers of BEL races:\",df_complete.loc[df_complete[\"track_id\"]==\"BEL\",\"program_number\"].unique())\nprint(\"Program numbers of SAR races:\",df_complete.loc[df_complete[\"track_id\"]==\"SAR\",\"program_number\"].unique())","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:17.113158Z","iopub.execute_input":"2022-09-20T11:55:17.113928Z","iopub.status.idle":"2022-09-20T11:55:18.661970Z","shell.execute_reply.started":"2022-09-20T11:55:17.113879Z","shell.execute_reply":"2022-09-20T11:55:18.660818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"trakus_index\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center;font-style:italic; '>\"trakus_index\": \"The common collection of point of the lat / long of the horse in the race passed as an integer. From what we can tell, it's collected every 0.25 seconds.\"</div></b> \n","metadata":{}},{"cell_type":"code","source":"print(\"trakus_index, min and max values of all races:\",df_complete[\"trakus_index\"].min(),df_complete[\"trakus_index\"].max())\nprint(\"trakus_index, min and max values of AQU races:\",df_aqu[\"trakus_index\"].min(),df_aqu[\"trakus_index\"].max())\nprint(\"trakus_index, min and max values of BEL races:\",df_bel[\"trakus_index\"].min(),df_bel[\"trakus_index\"].max())\nprint(\"trakus_index, min and max values of SAR races:\",df_sar[\"trakus_index\"].min(),df_sar[\"trakus_index\"].max())","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:18.664220Z","iopub.execute_input":"2022-09-20T11:55:18.665156Z","iopub.status.idle":"2022-09-20T11:55:18.696915Z","shell.execute_reply.started":"2022-09-20T11:55:18.665111Z","shell.execute_reply":"2022-09-20T11:55:18.695747Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set_palette(\"hls\")\n\nfig, ax = plt.subplots(figsize=(20,5))\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"trakus_index\")\nloc = plticker.MultipleLocator(base=100)\nax.xaxis.set_major_locator(loc)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:18.698024Z","iopub.execute_input":"2022-09-20T11:55:18.698376Z","iopub.status.idle":"2022-09-20T11:55:33.344640Z","shell.execute_reply.started":"2022-09-20T11:55:18.698342Z","shell.execute_reply":"2022-09-20T11:55:33.343523Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"latitude\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"print(\"latitude, min and max values of all races:\",df_complete[\"latitude\"].min(),df_complete[\"latitude\"].max())\nprint(\"latitude, min and max values of AQU races:\",df_aqu[\"latitude\"].min(),df_aqu[\"latitude\"].max())\nprint(\"latitude, min and max values of BEL races:\",df_bel[\"latitude\"].min(),df_bel[\"latitude\"].max())\nprint(\"latitude, min and max values of SAR races:\",df_sar[\"latitude\"].min(),df_sar[\"latitude\"].max())","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:33.346045Z","iopub.execute_input":"2022-09-20T11:55:33.346402Z","iopub.status.idle":"2022-09-20T11:55:33.409372Z","shell.execute_reply.started":"2022-09-20T11:55:33.346369Z","shell.execute_reply":"2022-09-20T11:55:33.408222Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"longitude\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"print(\"longitude, min and max values of all races:\",df_complete[\"longitude\"].min(),df_complete[\"longitude\"].max())\nprint(\"longitude, min and max values of AQU races:\",df_aqu[\"longitude\"].min(),df_aqu[\"longitude\"].max())\nprint(\"longitude, min and max values of BEL races:\",df_bel[\"longitude\"].min(),df_bel[\"longitude\"].max())\nprint(\"longitude, min and max values of SAR races:\",df_sar[\"longitude\"].min(),df_sar[\"longitude\"].max())","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:33.411326Z","iopub.execute_input":"2022-09-20T11:55:33.412265Z","iopub.status.idle":"2022-09-20T11:55:33.474997Z","shell.execute_reply.started":"2022-09-20T11:55:33.412216Z","shell.execute_reply":"2022-09-20T11:55:33.473831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>Picturing coordinates</div></b> ","metadata":{}},{"cell_type":"code","source":"from urllib.request import urlopen\nimport json\n\nwith urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:\n    counties = json.load(response)\n\n\nfig = px.choropleth_mapbox(df_complete.iloc[::100, :], geojson=counties, #color='track_id',#locations='fips', \n                           color_continuous_scale=\"Viridis\",\n                           range_color=(0, 12),\n                           mapbox_style=\"carto-positron\",\n                           zoom=6, \n                           center = {\"lat\": 42, \"lon\": -73.8},\n                          )\n\nfig.add_trace(px.scatter_mapbox(df_complete.iloc[::100, :], lat=\"latitude\", lon=\"longitude\",color=\"track_id\").data[0])\nfig.add_trace(px.scatter_mapbox(df_complete.iloc[::100, :], lat=\"latitude\", lon=\"longitude\",color=\"track_id\").data[1])\nfig.add_trace(px.scatter_mapbox(df_complete.iloc[::100, :], lat=\"latitude\", lon=\"longitude\",color=\"track_id\").data[2])\n\nfig.update_layout(margin={\"r\":0,\"t\":30,\"l\":0,\"b\":0},title=\"Racing Locations\")\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:33.476840Z","iopub.execute_input":"2022-09-20T11:55:33.477317Z","iopub.status.idle":"2022-09-20T11:55:37.766733Z","shell.execute_reply.started":"2022-09-20T11:55:33.477254Z","shell.execute_reply":"2022-09-20T11:55:37.765169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.choropleth_mapbox(df_complete.iloc[::100, :], geojson=counties, #color='track_id',#locations='fips', \n                           color_continuous_scale=\"Viridis\",\n                           range_color=(0, 12),\n                           mapbox_style=\"carto-positron\",\n                           zoom=13, \n                           center = {\"lat\": 40.673, \"lon\": -73.830},\n                          )\nfig.update_layout(margin={\"r\":0,\"t\":30,\"l\":0,\"b\":0},title=\"Aqueduct\")\n\nfig.add_trace(px.scatter_mapbox(df_complete.iloc[::100, :], lat=\"latitude\", lon=\"longitude\",color=\"track_id\").data[0])\n\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:37.768035Z","iopub.execute_input":"2022-09-20T11:55:37.768573Z","iopub.status.idle":"2022-09-20T11:55:40.551421Z","shell.execute_reply.started":"2022-09-20T11:55:37.768538Z","shell.execute_reply":"2022-09-20T11:55:40.550028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.choropleth_mapbox(df_complete.iloc[::100, :], geojson=counties, #color='track_id',#locations='fips', \n                           color_continuous_scale=\"Viridis\",\n                           range_color=(0, 12),\n                           mapbox_style=\"carto-positron\",\n                           zoom=13, \n                           center = {\"lat\": 40.715, \"lon\": -73.724},\n                          )\nfig.update_layout(margin={\"r\":0,\"t\":30,\"l\":0,\"b\":0},title=\"Belmont\")\n\nfig.add_trace(px.scatter_mapbox(df_complete.iloc[::100, :], lat=\"latitude\", lon=\"longitude\",color=\"track_id\").data[1])\n\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:40.553116Z","iopub.execute_input":"2022-09-20T11:55:40.553777Z","iopub.status.idle":"2022-09-20T11:55:43.338664Z","shell.execute_reply.started":"2022-09-20T11:55:40.553735Z","shell.execute_reply":"2022-09-20T11:55:43.337373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.choropleth_mapbox(df_complete.iloc[::100, :], geojson=counties, #color='track_id',#locations='fips', \n                           color_continuous_scale=\"Viridis\",\n                           range_color=(0, 12),\n                           mapbox_style=\"carto-positron\",\n                           zoom=13, \n                           center = {\"lat\": 43.072, \"lon\": -73.768},\n                          )\nfig.update_layout(margin={\"r\":0,\"t\":30,\"l\":0,\"b\":0},title=\"Saratoga\")\n\nfig.add_trace(px.scatter_mapbox(df_complete.iloc[::100, :], lat=\"latitude\", lon=\"longitude\",color=\"track_id\").data[2])\n\n\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:43.340218Z","iopub.execute_input":"2022-09-20T11:55:43.340650Z","iopub.status.idle":"2022-09-20T11:55:45.934561Z","shell.execute_reply.started":"2022-09-20T11:55:43.340614Z","shell.execute_reply":"2022-09-20T11:55:45.933368Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"distance_id\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"distance_id\": \"Distance of the race in furlongs passed as an integer. Example - 600 would be 6 furlongs.\"</div></b> \n\n","metadata":{}},{"cell_type":"code","source":"sns.set_palette(\"hls\")\n\nfig, ax = plt.subplots(figsize=(20,8))\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"distance_id\")\nloc = plticker.MultipleLocator(base=5)\nax.xaxis.set_major_locator(loc)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:45.936015Z","iopub.execute_input":"2022-09-20T11:55:45.936455Z","iopub.status.idle":"2022-09-20T11:55:49.145431Z","shell.execute_reply.started":"2022-09-20T11:55:45.936416Z","shell.execute_reply":"2022-09-20T11:55:49.144401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"course_type\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"sns.set_palette(\"hls\")\n\nfig, ax = plt.subplots()\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"course_type\")","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:49.146588Z","iopub.execute_input":"2022-09-20T11:55:49.146906Z","iopub.status.idle":"2022-09-20T11:55:55.157405Z","shell.execute_reply.started":"2022-09-20T11:55:49.146877Z","shell.execute_reply":"2022-09-20T11:55:55.156403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>M - Hurdle, D - Dirt, O - Outer turf, I - Inner turf, T - turf</div></b> ","metadata":{}},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"track_condition\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"sns.set_palette(\"hls\")\n\nfig, ax = plt.subplots()\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax,x=\"track_condition\")","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:55:55.158892Z","iopub.execute_input":"2022-09-20T11:55:55.159227Z","iopub.status.idle":"2022-09-20T11:56:01.299067Z","shell.execute_reply.started":"2022-09-20T11:55:55.159197Z","shell.execute_reply":"2022-09-20T11:56:01.298003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center;font-style:italic; '>YL - Yielding, FM - Firm, SY - Sloppy, GD - Good, FT - Fast, MY - Muddy, SF - Soft</div></b> ","metadata":{}},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"run_up_distance\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"run_up_distance\": \"Distance in feet of the gate to the start of the race passed as an integer.\"</div></b> ","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(2,2,figsize=(20,10))\n\nsns.histplot(data=df_complete,hue=\"track_id\", ax=ax[0,0],x=\"run_up_distance\")\nax[0,0].set_title(\"All Races\", fontsize=20)\n\nsns.histplot(data=df_aqu,hue=\"track_id\", ax=ax[0,1],x=\"run_up_distance\")\nax[0,1].set_title(\"Aqueduct\", fontsize=20)\n\nsns.histplot(data=df_bel,hue=\"track_id\", ax=ax[1,0],x=\"run_up_distance\")\nax[1,0].set_title(\"Belmont\", fontsize=20)\n\nsns.histplot(data=df_sar,hue=\"track_id\", ax=ax[1,1],x=\"run_up_distance\")\nax[1,1].set_title(\"Saratoga\", fontsize=20)\n\nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=0.4)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:56:01.300496Z","iopub.execute_input":"2022-09-20T11:56:01.300818Z","iopub.status.idle":"2022-09-20T11:56:23.197308Z","shell.execute_reply.started":"2022-09-20T11:56:01.300789Z","shell.execute_reply":"2022-09-20T11:56:23.196172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"race_type\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(2,2,figsize=(20,10))\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax[0,0],x=\"race_type\")\nax[0,0].set_title(\"All Races\", fontsize=20)\n\nsns.countplot(data=df_aqu,hue=\"track_id\", ax=ax[0,1],x=\"race_type\")\nax[0,1].set_title(\"Aqueduct\", fontsize=20)\n\nsns.countplot(data=df_bel,hue=\"track_id\", ax=ax[1,0],x=\"race_type\")\nax[1,0].set_title(\"Belmont\", fontsize=20)\n\nsns.countplot(data=df_sar,hue=\"track_id\", ax=ax[1,1],x=\"race_type\")\nax[1,1].set_title(\"Saratoga\", fontsize=20)\n\nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=0.4)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:56:23.199023Z","iopub.execute_input":"2022-09-20T11:56:23.199627Z","iopub.status.idle":"2022-09-20T11:56:35.092060Z","shell.execute_reply.started":"2022-09-20T11:56:23.199592Z","shell.execute_reply":"2022-09-20T11:56:35.090898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>STK - Stakes, WCL - Waiver Claiming, WMC - Waiver Maiden Claiming, SST - Starter Stakes, SHP - Starter Handicap, CLM - Claiming, STR - Starter Allowance, AOC - Allowance Optionl Claimer, SOC - Starter Optional Claimer, MCL - Maiden Claiming, ALW - Allowance, MSW - Maiden Special Weight.</div></b> ","metadata":{}},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"purse\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"purse\": \"Purse in US dollars of the race passed as a money with two decimal places.\"</div></b> ","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(2,2,figsize=(20,10))\n\nsns.histplot(data=df_complete,hue=\"track_id\", ax=ax[0,0],x=\"purse\")\nax[0,0].set_title(\"All Races\", fontsize=20)\n#ax[0,0].tick_params(axis='both', which='major', labelsize=8)\n#loc = plticker.MultipleLocator(base=5)\n#ax[0,0].xaxis.set_major_locator(loc)\n\n\nsns.histplot(data=df_aqu,hue=\"track_id\", ax=ax[0,1],x=\"purse\")\nax[0,1].set_title(\"Aqueduct\", fontsize=20)\n\nsns.histplot(data=df_bel,hue=\"track_id\", ax=ax[1,0],x=\"purse\")\nax[1,0].set_title(\"Belmont\", fontsize=20)\n\nsns.histplot(data=df_sar,hue=\"track_id\", ax=ax[1,1],x=\"purse\")\nax[1,1].set_title(\"Saratoga\", fontsize=20)\n\nfor n in range(2):\n    for m in range(2):\n        for tick in ax[n,m].get_xticklabels():\n            tick.set_rotation(90)\n    \nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=0.4)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:56:35.093920Z","iopub.execute_input":"2022-09-20T11:56:35.094398Z","iopub.status.idle":"2022-09-20T11:57:22.085100Z","shell.execute_reply.started":"2022-09-20T11:56:35.094353Z","shell.execute_reply":"2022-09-20T11:57:22.084133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"post_time\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"post_time\": \"Time of day the race began passed as 5 character. Example - 01220 would be 12:20.\"</div></b>","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(2,2,figsize=(20,10))\n\nsns.histplot(data=df_complete,hue=\"track_id\", ax=ax[0,0],x=\"post_time\")\nax[0,0].set_title(\"All Races\", fontsize=20)\n#ax[0,0].tick_params(axis='both', which='major', labelsize=8)\n#loc = plticker.MultipleLocator(base=10)\n#ax[0,0].xaxis.set_major_locator(loc)\n\n\nsns.histplot(data=df_aqu,hue=\"track_id\", ax=ax[0,1],x=\"post_time\")\nax[0,1].set_title(\"Aqueduct\", fontsize=20)\n\nsns.histplot(data=df_bel,hue=\"track_id\", ax=ax[1,0],x=\"post_time\")\nax[1,0].set_title(\"Belmont\", fontsize=20)\n\nsns.histplot(data=df_sar,hue=\"track_id\", ax=ax[1,1],x=\"post_time\")\nax[1,1].set_title(\"Saratoga\", fontsize=20)\n\n\nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=0.4)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:57:22.086377Z","iopub.execute_input":"2022-09-20T11:57:22.086791Z","iopub.status.idle":"2022-09-20T11:57:39.480529Z","shell.execute_reply.started":"2022-09-20T11:57:22.086761Z","shell.execute_reply":"2022-09-20T11:57:39.479093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"weight_carried\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(2,2,figsize=(20,10))\n\nsns.histplot(data=df_complete,hue=\"track_id\", ax=ax[0,0],x=\"weight_carried\")\nax[0,0].set_title(\"All Races\", fontsize=20)\n\nsns.histplot(data=df_aqu,hue=\"track_id\", ax=ax[0,1],x=\"weight_carried\")\nax[0,1].set_title(\"Aqueduct\", fontsize=20)\n\nsns.histplot(data=df_bel,hue=\"track_id\", ax=ax[1,0],x=\"weight_carried\")\nax[1,0].set_title(\"Belmont\", fontsize=20)\n\nsns.histplot(data=df_sar,hue=\"track_id\", ax=ax[1,1],x=\"weight_carried\")\nax[1,1].set_title(\"Saratoga\", fontsize=20)\n\nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=0.4)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:57:39.481865Z","iopub.execute_input":"2022-09-20T11:57:39.482300Z","iopub.status.idle":"2022-09-20T11:58:03.357776Z","shell.execute_reply.started":"2022-09-20T11:57:39.482252Z","shell.execute_reply":"2022-09-20T11:58:03.356710Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"jockey\" column</div></b> ","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(4,1,figsize=(20,20))\n\nsns.countplot(data=df_complete,hue=\"track_id\", ax=ax[0],x=\"jockey\",order=df_complete.jockey.value_counts().iloc[:25].index)\nax[0].set_title(\"most frequent 25 jockeys at all races\", fontsize=20)\n#ax[0,0].tick_params(axis='both', which='major', labelsize=8)\n#loc = plticker.MultipleLocator(base=10)\n#ax[0,0].xaxis.set_major_locator(loc)\n\n\nsns.countplot(data=df_aqu,hue=\"track_id\", ax=ax[1],x=\"jockey\",order=df_aqu.jockey.value_counts().iloc[:25].index)\nax[1].set_title(\"most frequent 25 jockeys at Aqueduct\", fontsize=20)\n\nsns.countplot(data=df_bel,hue=\"track_id\", ax=ax[2],x=\"jockey\",order=df_bel.jockey.value_counts().iloc[:25].index)\nax[2].set_title(\"most frequent 25 jockeys at Belmont\", fontsize=20)\n\nsns.countplot(data=df_sar,hue=\"track_id\", ax=ax[3],x=\"jockey\",order=df_sar.jockey.value_counts().iloc[:25].index)\nax[3].set_title(\"most frequent 25 jockeys at Saratoga\", fontsize=20)\n\nfor n in range(4):\n    for tick in ax[n].get_xticklabels():\n        tick.set_rotation(45)\n    \nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=1)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:58:03.362531Z","iopub.execute_input":"2022-09-20T11:58:03.362889Z","iopub.status.idle":"2022-09-20T11:58:14.768743Z","shell.execute_reply.started":"2022-09-20T11:58:03.362857Z","shell.execute_reply":"2022-09-20T11:58:14.766232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# <b><div style='padding:12px;background-color:#42855B;border-radius:2px;color:#D2D79F;font-size:25pt;font-family:    serif;text-align:center; '>\"odds\" column</div></b> ","metadata":{}},{"cell_type":"markdown","source":"<b><div style='padding:12px;background-color:#D2D79F;border-radius:35px;color:#483838;font-size:16pt;font-family:    serif;text-align:center; font-style:italic;'>\"odds\": \"Odds to win the race passed as an integer. Divide by 100 to derive the odds to 1. Example - 1280 would be 12.8-1.\"</div></b>\n","metadata":{}},{"cell_type":"code","source":"fig, ax = plt.subplots(2,2,figsize=(20,10))\n\nsns.histplot(data=df_complete,hue=\"track_id\", ax=ax[0,0],x=\"odds\")\nax[0,0].set_title(\"All Races\", fontsize=20)\n#ax[0,0].tick_params(axis='both', which='major', labelsize=8)\n#loc = plticker.MultipleLocator(base=10)\n#ax[0,0].xaxis.set_major_locator(loc)\n\n\nsns.histplot(data=df_aqu,hue=\"track_id\", ax=ax[0,1],x=\"odds\")\nax[0,1].set_title(\"Aqueduct\", fontsize=20)\n\nsns.histplot(data=df_bel,hue=\"track_id\", ax=ax[1,0],x=\"odds\")\nax[1,0].set_title(\"Belmont\", fontsize=20)\n\nsns.histplot(data=df_sar,hue=\"track_id\", ax=ax[1,1],x=\"odds\")\nax[1,1].set_title(\"Saratoga\", fontsize=20)\n\n    \nplt.subplots_adjust(left=None,\n                    bottom=None, \n                    right=None, \n                    top=None, \n                    wspace=None, \n                    hspace=0.25)","metadata":{"execution":{"iopub.status.busy":"2022-09-20T11:58:14.771912Z","iopub.execute_input":"2022-09-20T11:58:14.773554Z","iopub.status.idle":"2022-09-20T11:58:41.346886Z","shell.execute_reply.started":"2022-09-20T11:58:14.773513Z","shell.execute_reply":"2022-09-20T11:58:41.345723Z"},"trusted":true},"execution_count":null,"outputs":[]}]}