{"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":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport plotly.express as px #graphing\nimport plotly.graph_objects as go #graphing\nfrom plotly.subplots import make_subplots #graphing\nimport plotly.figure_factory as ff #graphing\nimport matplotlib.pyplot as plt #graphing\nimport seaborn as sns #graphing\nimport missingno as msno #describe data\nimport os\n\ncolors = [\"#FFFFFF\", \"#6CD4FF\", \"#F7DF00\", \"#E60000\"]\n\nfrom plotly.offline import plot, iplot, init_notebook_mode\nimport plotly.graph_objs as go\ninit_notebook_mode(connected=True)\n\nplt.rcParams[\"figure.figsize\"] = (12, 8)\n\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-29T23:24:45.257463Z","iopub.execute_input":"2022-08-29T23:24:45.258206Z","iopub.status.idle":"2022-08-29T23:24:49.223057Z","shell.execute_reply.started":"2022-08-29T23:24:45.258115Z","shell.execute_reply":"2022-08-29T23:24:49.221416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_tracking_table.csv\")\nnyra_start = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_start_table.csv\")\nnyra_race = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_race_table.csv\")\nnyra_2019 = pd.read_csv(\"/kaggle/input/big-data-derby-2022/nyra_2019_complete.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:25:32.665749Z","iopub.execute_input":"2022-08-29T23:25:32.666131Z","iopub.status.idle":"2022-08-29T23:25:51.719421Z","shell.execute_reply.started":"2022-08-29T23:25:32.666099Z","shell.execute_reply":"2022-08-29T23:25:51.718441Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_2019.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:26:07.871332Z","iopub.execute_input":"2022-08-29T23:26:07.871715Z","iopub.status.idle":"2022-08-29T23:26:07.899222Z","shell.execute_reply.started":"2022-08-29T23:26:07.871682Z","shell.execute_reply":"2022-08-29T23:26:07.898113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_2019.describe().style.background_gradient(cmap = \"pink\")","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:28:06.047107Z","iopub.execute_input":"2022-08-29T23:28:06.047480Z","iopub.status.idle":"2022-08-29T23:28:07.658549Z","shell.execute_reply.started":"2022-08-29T23:28:06.047448Z","shell.execute_reply":"2022-08-29T23:28:07.657448Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.track_id.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:28:33.745561Z","iopub.execute_input":"2022-08-29T23:28:33.745929Z","iopub.status.idle":"2022-08-29T23:28:34.023025Z","shell.execute_reply.started":"2022-08-29T23:28:33.745896Z","shell.execute_reply":"2022-08-29T23:28:34.021922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.race_number.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:28:47.646172Z","iopub.execute_input":"2022-08-29T23:28:47.646559Z","iopub.status.idle":"2022-08-29T23:28:47.694312Z","shell.execute_reply.started":"2022-08-29T23:28:47.646523Z","shell.execute_reply":"2022-08-29T23:28:47.693199Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking.program_number.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:28:58.986920Z","iopub.execute_input":"2022-08-29T23:28:58.987449Z","iopub.status.idle":"2022-08-29T23:28:59.284567Z","shell.execute_reply.started":"2022-08-29T23:28:58.987398Z","shell.execute_reply":"2022-08-29T23:28:59.283415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking['race_date'] = pd.to_datetime(nyra_tracking['race_date'])\nnyra_tracking['day'], nyra_tracking['month'] = nyra_tracking['race_date'].dt.day, nyra_tracking['race_date'].dt.month","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:29:23.556948Z","iopub.execute_input":"2022-08-29T23:29:23.557317Z","iopub.status.idle":"2022-08-29T23:29:25.250435Z","shell.execute_reply.started":"2022-08-29T23:29:23.557286Z","shell.execute_reply":"2022-08-29T23:29:25.249318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking0 = nyra_tracking[nyra_tracking[\"track_id\"] == \"AQU\"]\nnyra_tracking1 = nyra_tracking0[nyra_tracking0[\"month\"] == 11]\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = nyra_tracking1, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = \"Paired\")\n\nplt.title(\"track_id = AQU, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:29:46.525725Z","iopub.execute_input":"2022-08-29T23:29:46.526317Z","iopub.status.idle":"2022-08-29T23:30:11.385199Z","shell.execute_reply.started":"2022-08-29T23:29:46.526272Z","shell.execute_reply":"2022-08-29T23:30:11.384364Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking0 = nyra_tracking[nyra_tracking[\"track_id\"] == \"BEL\"]\nnyra_tracking1 = nyra_tracking0[nyra_tracking0[\"month\"] == 5]\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = nyra_tracking1, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = \"Paired\")\n\nplt.title(\"track_id = BEL, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:30:35.446177Z","iopub.execute_input":"2022-08-29T23:30:35.446565Z","iopub.status.idle":"2022-08-29T23:30:53.848103Z","shell.execute_reply.started":"2022-08-29T23:30:35.446531Z","shell.execute_reply":"2022-08-29T23:30:53.846554Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_tracking0 = nyra_tracking[nyra_tracking[\"track_id\"] == \"SAR\"]\nnyra_tracking1 = nyra_tracking0[nyra_tracking0[\"month\"] == 9]\n\nplt.style.use(\"dark_background\")\nplt.figure(figsize = (16, 8))\nsns.scatterplot(data = nyra_tracking1, x = \"longitude\", y = \"latitude\", hue = \"race_number\", palette = \"Paired\")\n\nplt.title(\"track_id = SAR, Longitude and Latitude by Race Number\")\nplt.legend()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:30:53.850276Z","iopub.execute_input":"2022-08-29T23:30:53.850952Z","iopub.status.idle":"2022-08-29T23:30:57.345142Z","shell.execute_reply.started":"2022-08-29T23:30:53.850914Z","shell.execute_reply":"2022-08-29T23:30:57.344238Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_2019.race_number.hist(bins = 12)","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:31:20.242479Z","iopub.execute_input":"2022-08-29T23:31:20.242990Z","iopub.status.idle":"2022-08-29T23:31:20.605338Z","shell.execute_reply.started":"2022-08-29T23:31:20.242956Z","shell.execute_reply":"2022-08-29T23:31:20.604369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"jockey = nyra_2019[nyra_2019[\"jockey\"] == \"Samuel Camacho Jr.\"]\njockey6 = jockey[jockey[\"race_number\"] == 6]\njockeyBEL = jockey6[jockey6[\"track_id\"] == \"BEL\"]\njockeyALW = jockeyBEL[jockeyBEL[\"race_type\"] == \"ALW\"]\njockeyCLM = jockeyBEL[jockeyBEL[\"race_type\"] == \"CLM\"]\njockeyALW = jockeyALW.sort_values(by = \"trakus_index\", ascending = True)\n\nfig = px.scatter(jockeyALW, x = \"longitude\", y = \"latitude\", hover_data = [\"race_type\", \"track_id\"],\n                 animation_frame = \"longitude\",\n                 range_y = (40.7122, 40.718),\n                 range_x = (-73.719, -73.73),\n                 #size = \"trakus_index\",\n                 color = \"trakus_index\", color_continuous_scale = \"Turbo\", range_color = (0, 299),\n                 title = \"Samuel Camacho Jr. - Trakus Index,  Race Number = 6,  track_id = BEL\")\n\nfig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 30\nfig.layout.updatemenus[0].buttons[0].args[1]['transition']['duration'] = 5\nfig.update_traces(marker = dict(symbol = \"circle-open\", size = 20)) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:31:48.894771Z","iopub.execute_input":"2022-08-29T23:31:48.895159Z","iopub.status.idle":"2022-08-29T23:31:51.635862Z","shell.execute_reply.started":"2022-08-29T23:31:48.895125Z","shell.execute_reply":"2022-08-29T23:31:51.634820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"jockey = nyra_2019[nyra_2019[\"jockey\"] == \"Flavien Prat\"]\njockey6 = jockey[jockey[\"race_number\"] == 6]\njockeyBEL = jockey6[jockey6[\"track_id\"] == \"BEL\"]\njockeyALW = jockeyBEL[jockeyBEL[\"race_type\"] == \"ALW\"]\njockeyCLM = jockeyBEL[jockeyBEL[\"race_type\"] == \"CLM\"]\njockeyALW = jockeyALW.sort_values(by = \"trakus_index\", ascending = True)\n\nfig = px.scatter(jockeyALW, x = \"longitude\", y = \"latitude\", hover_data = [\"race_type\", \"track_id\"],\n                 animation_frame = \"longitude\",\n                 range_y = (40.7122, 40.718),\n                 range_x = (-73.719, -73.73),\n                # size = \"trakus_index\",\n                 color = \"trakus_index\", color_continuous_scale = \"Turbo\", range_color = (0, 299),\n                 title = \"Flavien Prat - Trakus Index,  Race Number = 6,  track_id = BEL\")\n\nfig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 30\nfig.layout.updatemenus[0].buttons[0].args[1]['transition']['duration'] = 5\nfig.update_traces(marker = dict(symbol = \"circle-open\", size = 20)) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:32:17.637355Z","iopub.execute_input":"2022-08-29T23:32:17.637977Z","iopub.status.idle":"2022-08-29T23:32:19.265049Z","shell.execute_reply.started":"2022-08-29T23:32:17.637937Z","shell.execute_reply":"2022-08-29T23:32:19.264161Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"jockey = nyra_2019[nyra_2019[\"jockey\"] == \"Flavien Prat\"]\nraces_bel = jockey[jockey[\"track_id\"] == 'BEL']\n\nfor odds in sorted([690, 650, 1840, 70, 520, 2140, 400, 2775, 700, 160, 1910, 1030, 660]):\n    \n    df0 = races_bel[races_bel[\"odds\"] == odds]\n    \n    fig = px.scatter(df0, x = \"longitude\", y = \"latitude\", opacity = 0.8,\n                     hover_data = [\"race_date\", \"distance_id\", \"purse\"],\n                     color = \"trakus_index\", color_continuous_scale = \"Turbo\", #range_color = (0, 399),\n                     title = f\"Flavien Prat Trakus Index Race Pathing,  Odds: {odds}  track_id = BEL\")\n\n    fig.update_traces(marker = dict(symbol = \"square-open\", size = 20)) # scaling the markers\n    fig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 12))\n    fig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:32:42.759671Z","iopub.execute_input":"2022-08-29T23:32:42.760306Z","iopub.status.idle":"2022-08-29T23:32:44.427850Z","shell.execute_reply.started":"2022-08-29T23:32:42.760268Z","shell.execute_reply":"2022-08-29T23:32:44.426567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_2019.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:33:29.900165Z","iopub.execute_input":"2022-08-29T23:33:29.901255Z","iopub.status.idle":"2022-08-29T23:33:29.920468Z","shell.execute_reply.started":"2022-08-29T23:33:29.901207Z","shell.execute_reply":"2022-08-29T23:33:29.919335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_start.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:33:42.934426Z","iopub.execute_input":"2022-08-29T23:33:42.935076Z","iopub.status.idle":"2022-08-29T23:33:42.949316Z","shell.execute_reply.started":"2022-08-29T23:33:42.935036Z","shell.execute_reply":"2022-08-29T23:33:42.948164Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_start['race_date'] = pd.to_datetime(nyra_start['race_date'])\nnyra_start['day'], nyra_start['month'] = nyra_start['race_date'].dt.day, nyra_start['race_date'].dt.month","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:33:56.294185Z","iopub.execute_input":"2022-08-29T23:33:56.294657Z","iopub.status.idle":"2022-08-29T23:33:56.310273Z","shell.execute_reply.started":"2022-08-29T23:33:56.294620Z","shell.execute_reply":"2022-08-29T23:33:56.309264Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"weight_carried\", y = \"odds\", hover_data = [\"race_number\", \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Weight Carried\")\n\nfig.update_traces(marker = dict(size = 8, symbol = \"circle\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:34:17.476485Z","iopub.execute_input":"2022-08-29T23:34:17.477181Z","iopub.status.idle":"2022-08-29T23:34:17.749413Z","shell.execute_reply.started":"2022-08-29T23:34:17.477145Z","shell.execute_reply":"2022-08-29T23:34:17.748537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"weight_carried\", y = \"day\", hover_data = [\"race_number\", \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Day of Event and Weight Carried\")\n\nfig.update_traces(marker = dict(size = 9, symbol = \"square\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:34:43.242100Z","iopub.execute_input":"2022-08-29T23:34:43.242467Z","iopub.status.idle":"2022-08-29T23:34:43.681717Z","shell.execute_reply.started":"2022-08-29T23:34:43.242434Z","shell.execute_reply":"2022-08-29T23:34:43.680594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_start, x = \"weight_carried\", y = \"month\", hover_data = [\"race_number\", \"jockey\"],\n                 color = \"odds\", color_continuous_scale = colors, range_color = (0, 9999),\n                 title = \"Odds by Month of Event and Weight Carried\")\n\nfig.update_traces(marker = dict(size = 11, symbol = \"circle\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:34:58.773613Z","iopub.execute_input":"2022-08-29T23:34:58.774629Z","iopub.status.idle":"2022-08-29T23:34:59.208962Z","shell.execute_reply.started":"2022-08-29T23:34:58.774589Z","shell.execute_reply":"2022-08-29T23:34:59.207413Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_race.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:35:12.249283Z","iopub.execute_input":"2022-08-29T23:35:12.249679Z","iopub.status.idle":"2022-08-29T23:35:12.263604Z","shell.execute_reply.started":"2022-08-29T23:35:12.249646Z","shell.execute_reply":"2022-08-29T23:35:12.262269Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"nyra_race.track_condition.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:35:24.170654Z","iopub.execute_input":"2022-08-29T23:35:24.171032Z","iopub.status.idle":"2022-08-29T23:35:24.179485Z","shell.execute_reply.started":"2022-08-29T23:35:24.170999Z","shell.execute_reply":"2022-08-29T23:35:24.178540Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fig = px.scatter(nyra_race, x = \"post_time\", y = \"run_up_distance\", hover_data = [\"race_number\", \"course_type\"],\n                 color = \"race_number\", color_discrete_sequence = colors, #range_color = (0, 9999),\n                 title = \"Post Time by Run Up Distance\")\n\nfig.update_traces(marker = dict(size = 4, symbol = \"circle\")) # scaling the markers\nfig.update_layout(template = \"plotly_dark\", font = dict(family = \"PT Sans\", size = 20))\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-29T23:35:46.840671Z","iopub.execute_input":"2022-08-29T23:35:46.841046Z","iopub.status.idle":"2022-08-29T23:35:46.945159Z","shell.execute_reply.started":"2022-08-29T23:35:46.841012Z","shell.execute_reply":"2022-08-29T23:35:46.943886Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}