{"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":"## Dataset description","metadata":{}},{"cell_type":"markdown","source":"The goal of this competition is to analyze horse racing tactics, drafting strategies, and path efficiency. You will develop a model using never-before-released coordinate data along with basic race information.\n\nYour work will help racing horse owners, trainers, and veterinarians better understand how equine performance and welfare fit together. With better data analysis, equine welfare could significantly improve.","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport seaborn as sns\nimport numpy as np\nimport os\nimport warnings # Supress warnings\nwarnings.filterwarnings(\"ignore\")\nimport matplotlib.pyplot as plt\nfrom datetime import datetime","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:44.620253Z","iopub.execute_input":"2022-11-14T11:31:44.620720Z","iopub.status.idle":"2022-11-14T11:31:45.072526Z","shell.execute_reply.started":"2022-11-14T11:31:44.620631Z","shell.execute_reply":"2022-11-14T11:31:45.071424Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.set(rc={\"figure.figsize\":(15, 5)})","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:45.074410Z","iopub.execute_input":"2022-11-14T11:31:45.074991Z","iopub.status.idle":"2022-11-14T11:31:45.081243Z","shell.execute_reply.started":"2022-11-14T11:31:45.074931Z","shell.execute_reply":"2022-11-14T11:31:45.080273Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('../input/big-data-derby-2022/nyra_2019_complete.csv',\n    parse_dates=['race_date'],\n    names=['track_id', 'race_date', 'race_number', 'program_number','trakus_index', 'latitude',\n           'longitude', 'distance_id', 'course_type', 'track_condition', 'run_up_distance',\n           'race_type', 'purse', 'post_time', 'weight_carried', 'jockey', 'odds', 'position_at_finish'])\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:45.082565Z","iopub.execute_input":"2022-11-14T11:31:45.083057Z","iopub.status.idle":"2022-11-14T11:31:52.107650Z","shell.execute_reply.started":"2022-11-14T11:31:45.083030Z","shell.execute_reply":"2022-11-14T11:31:52.106329Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start = pd.read_csv('../input/big-data-derby-2022/nyra_start_table.csv', \n                       header=None, \n                       parse_dates=['race_date'],\n                       names=['track_id',\n                              'race_date',\n                              'race_number',\n                              'program_number',\n                              'weight_carried',\n                              'jockey',\n                              'odds',\n                              'position_at_finish'])\ndf_start.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:52.110247Z","iopub.execute_input":"2022-11-14T11:31:52.110850Z","iopub.status.idle":"2022-11-14T11:31:52.142813Z","shell.execute_reply.started":"2022-11-14T11:31:52.110814Z","shell.execute_reply":"2022-11-14T11:31:52.141667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_race = pd.read_csv('../input/big-data-derby-2022/nyra_race_table.csv', parse_dates=['race_date'])\ndf_race.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:52.144357Z","iopub.execute_input":"2022-11-14T11:31:52.144733Z","iopub.status.idle":"2022-11-14T11:31:52.166508Z","shell.execute_reply.started":"2022-11-14T11:31:52.144696Z","shell.execute_reply":"2022-11-14T11:31:52.165456Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking = pd.read_csv('../input/big-data-derby-2022/nyra_tracking_table.csv', parse_dates=['race_date'])\ndf_tracking.head()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:31:52.168464Z","iopub.execute_input":"2022-11-14T11:31:52.169218Z","iopub.status.idle":"2022-11-14T11:31:55.682873Z","shell.execute_reply.started":"2022-11-14T11:31:52.169171Z","shell.execute_reply":"2022-11-14T11:31:55.681888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Dataset has 3 files merged into one nyra_2019_complete.","metadata":{}},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:55.684440Z","iopub.execute_input":"2022-11-14T11:31:55.684720Z","iopub.status.idle":"2022-11-14T11:31:55.697496Z","shell.execute_reply.started":"2022-11-14T11:31:55.684694Z","shell.execute_reply":"2022-11-14T11:31:55.695611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"File consists of 18 columns and 5 228 430 rows.","metadata":{}},{"cell_type":"markdown","source":"The meaning of the columns names provided by NYTHA/NYRA:\n - race_date: date the race took place. YYYY-MM-DD.\n - race_number: Number of the race. Passed as 3 characters but can be cast or converted to int for this data set.\n - program_number: Program number of the horse in the race passed as 3 characters. Should remain 3 characters as it isn't limited to just numbers. Is essentially the unique identifier of the horse in the race.\n - 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.\n - latitude: The latitude of the horse in the race passed as a float.\n - longitude: The longitude of the horse in the race passed as a float.\n - distance_id: Distance of the race in furlongs passed as an integer. Example - 600 would be 6 furlongs.\n - course_type: The course the race was run over passed as one character. M - Hurdle, D - Dirt, O - Outer turf, I - Inner turf, T - turf.\n - track_condition: The condition of the course the race was run on passed as three characters. YL - Yielding, FM - Firm, SY - Sloppy, GD - Good, FT - Fast, MY - Muddy, SF - Soft.\n - run_up_distance: Distance in feet of the gate to the start of the race passed as an integer.\n - race_type: The classification of the race passed as as five characters. 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.\n - purse: Purse in US dollars of the race passed as an money with two decimal places.\n - post_time: Time of day the race began passed as 5 character. Example - 01220 would be 12:20.\n - weight_carried: An integer of the weight carried by the horse in the race.\n - jockey: Name of the jockey on the horse in the race. 50 character max.\n - 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.\n - position_at_finish: An integer of the horse's finishing position.\n \n Dataset contains following data types: datetime64[ns](1), float64(3), int64(8), object(6).","metadata":{}},{"cell_type":"markdown","source":"## Data types changing","metadata":{}},{"cell_type":"markdown","source":"### program_number","metadata":{}},{"cell_type":"code","source":"df.program_number.unique() # unique values of the column","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:31:55.699241Z","iopub.execute_input":"2022-11-14T11:31:55.699629Z","iopub.status.idle":"2022-11-14T11:31:55.836563Z","shell.execute_reply.started":"2022-11-14T11:31:55.699593Z","shell.execute_reply":"2022-11-14T11:31:55.835687Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"We see object and int number formats at the same time.","metadata":{}},{"cell_type":"code","source":"df['program_number'] = df['program_number'].astype(str) # entire column to str\ndf['program_number'] = df['program_number'].str.strip() # strip spaces","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:55.837753Z","iopub.execute_input":"2022-11-14T11:31:55.838906Z","iopub.status.idle":"2022-11-14T11:31:57.724018Z","shell.execute_reply.started":"2022-11-14T11:31:55.838858Z","shell.execute_reply":"2022-11-14T11:31:57.722416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### post_time","metadata":{}},{"cell_type":"code","source":"df.post_time.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:57.728792Z","iopub.execute_input":"2022-11-14T11:31:57.729148Z","iopub.status.idle":"2022-11-14T11:31:57.759699Z","shell.execute_reply.started":"2022-11-14T11:31:57.729118Z","shell.execute_reply":"2022-11-14T11:31:57.758398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# <function to 24h>\ndef new_hours(row):\n    time = row['post_time']\n    if len(str(time)) == 3:\n        return time + 1200\n    else:\n        return time","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:57.761089Z","iopub.execute_input":"2022-11-14T11:31:57.761428Z","iopub.status.idle":"2022-11-14T11:31:57.767481Z","shell.execute_reply.started":"2022-11-14T11:31:57.761399Z","shell.execute_reply":"2022-11-14T11:31:57.766313Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['post_time'] = df.apply(new_hours, axis = 1) # apply new_time function","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:31:57.769382Z","iopub.execute_input":"2022-11-14T11:31:57.769755Z","iopub.status.idle":"2022-11-14T11:33:08.202436Z","shell.execute_reply.started":"2022-11-14T11:31:57.769719Z","shell.execute_reply":"2022-11-14T11:33:08.200704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['post_time'] = df['post_time'].astype(str) # entire column to str","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:33:08.204114Z","iopub.execute_input":"2022-11-14T11:33:08.204611Z","iopub.status.idle":"2022-11-14T11:33:10.740494Z","shell.execute_reply.started":"2022-11-14T11:33:08.204572Z","shell.execute_reply":"2022-11-14T11:33:10.738553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# <function to separate hours and minutes>\ndef new_time(row):\n    word = row['post_time']\n    if len(word) == 3:\n        position = 1\n        return word[:position] + ':' + word[position:]\n    else:\n        position = 2\n        return word[:position] + ':' + word[position:]","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:33:10.742526Z","iopub.execute_input":"2022-11-14T11:33:10.743007Z","iopub.status.idle":"2022-11-14T11:33:10.750040Z","shell.execute_reply.started":"2022-11-14T11:33:10.742968Z","shell.execute_reply":"2022-11-14T11:33:10.748862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['post_time'] = df.apply(new_time, axis = 1) # apply new_time function","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:33:10.751372Z","iopub.execute_input":"2022-11-14T11:33:10.752962Z","iopub.status.idle":"2022-11-14T11:34:20.815961Z","shell.execute_reply.started":"2022-11-14T11:33:10.752888Z","shell.execute_reply":"2022-11-14T11:34:20.814391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['post_time'] = pd.to_datetime(df['post_time'], format = '%H:%M') # change to datetime type","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:34:20.817382Z","iopub.execute_input":"2022-11-14T11:34:20.817727Z","iopub.status.idle":"2022-11-14T11:34:22.022244Z","shell.execute_reply.started":"2022-11-14T11:34:20.817695Z","shell.execute_reply":"2022-11-14T11:34:22.020802Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['date_post_time'] = pd.to_datetime(df.race_date.dt.strftime('%Y-%m-%d ') +\n                            df.post_time.dt.strftime('%H'))\ndf.info()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:34:22.024050Z","iopub.execute_input":"2022-11-14T11:34:22.024405Z","iopub.status.idle":"2022-11-14T11:35:05.054305Z","shell.execute_reply.started":"2022-11-14T11:34:22.024374Z","shell.execute_reply":"2022-11-14T11:35:05.052831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:05.055931Z","iopub.execute_input":"2022-11-14T11:35:05.056350Z","iopub.status.idle":"2022-11-14T11:35:05.075818Z","shell.execute_reply.started":"2022-11-14T11:35:05.056302Z","shell.execute_reply":"2022-11-14T11:35:05.075131Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Conclusions","metadata":{}},{"cell_type":"markdown","source":"We have changes 3 column types:\n- program_number from object+int to object\n- post_time from int to datetime","metadata":{}},{"cell_type":"markdown","source":"## Unique values","metadata":{}},{"cell_type":"code","source":"df.nunique()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:05.076981Z","iopub.execute_input":"2022-11-14T11:35:05.077463Z","iopub.status.idle":"2022-11-14T11:35:09.165216Z","shell.execute_reply.started":"2022-11-14T11:35:05.077438Z","shell.execute_reply":"2022-11-14T11:35:09.163369Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.track_id.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:09.167104Z","iopub.execute_input":"2022-11-14T11:35:09.167482Z","iopub.status.idle":"2022-11-14T11:35:09.461710Z","shell.execute_reply.started":"2022-11-14T11:35:09.167448Z","shell.execute_reply":"2022-11-14T11:35:09.460220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.race_date.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:09.463566Z","iopub.execute_input":"2022-11-14T11:35:09.464618Z","iopub.status.idle":"2022-11-14T11:35:09.493905Z","shell.execute_reply.started":"2022-11-14T11:35:09.464573Z","shell.execute_reply":"2022-11-14T11:35:09.493003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.race_number.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:09.495095Z","iopub.execute_input":"2022-11-14T11:35:09.495395Z","iopub.status.idle":"2022-11-14T11:35:09.520517Z","shell.execute_reply.started":"2022-11-14T11:35:09.495367Z","shell.execute_reply":"2022-11-14T11:35:09.519587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.program_number.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:09.521969Z","iopub.execute_input":"2022-11-14T11:35:09.522338Z","iopub.status.idle":"2022-11-14T11:35:09.818618Z","shell.execute_reply.started":"2022-11-14T11:35:09.522296Z","shell.execute_reply":"2022-11-14T11:35:09.817363Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.distance_id.unique()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:09.820576Z","iopub.execute_input":"2022-11-14T11:35:09.820957Z","iopub.status.idle":"2022-11-14T11:35:09.848129Z","shell.execute_reply.started":"2022-11-14T11:35:09.820907Z","shell.execute_reply":"2022-11-14T11:35:09.846492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.course_type.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:09.850156Z","iopub.execute_input":"2022-11-14T11:35:09.850497Z","iopub.status.idle":"2022-11-14T11:35:10.138334Z","shell.execute_reply.started":"2022-11-14T11:35:09.850466Z","shell.execute_reply":"2022-11-14T11:35:10.137065Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.track_condition.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:10.140017Z","iopub.execute_input":"2022-11-14T11:35:10.140336Z","iopub.status.idle":"2022-11-14T11:35:10.436589Z","shell.execute_reply.started":"2022-11-14T11:35:10.140308Z","shell.execute_reply":"2022-11-14T11:35:10.435044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.run_up_distance.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:10.438188Z","iopub.execute_input":"2022-11-14T11:35:10.438663Z","iopub.status.idle":"2022-11-14T11:35:10.464279Z","shell.execute_reply.started":"2022-11-14T11:35:10.438626Z","shell.execute_reply":"2022-11-14T11:35:10.463492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.race_type.unique()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:10.471360Z","iopub.execute_input":"2022-11-14T11:35:10.471718Z","iopub.status.idle":"2022-11-14T11:35:10.768663Z","shell.execute_reply.started":"2022-11-14T11:35:10.471688Z","shell.execute_reply":"2022-11-14T11:35:10.767101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.purse.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:10.769886Z","iopub.execute_input":"2022-11-14T11:35:10.770230Z","iopub.status.idle":"2022-11-14T11:35:10.815763Z","shell.execute_reply.started":"2022-11-14T11:35:10.770200Z","shell.execute_reply":"2022-11-14T11:35:10.814045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"As purse is int number we change its type.","metadata":{}},{"cell_type":"code","source":"df['purse'] = df['purse'].astype(int) # entire column to str","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:10.818121Z","iopub.execute_input":"2022-11-14T11:35:10.818614Z","iopub.status.idle":"2022-11-14T11:35:10.849372Z","shell.execute_reply.started":"2022-11-14T11:35:10.818577Z","shell.execute_reply":"2022-11-14T11:35:10.847585Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.post_time.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:10.851098Z","iopub.execute_input":"2022-11-14T11:35:10.851513Z","iopub.status.idle":"2022-11-14T11:35:10.885294Z","shell.execute_reply.started":"2022-11-14T11:35:10.851481Z","shell.execute_reply":"2022-11-14T11:35:10.884093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.weight_carried.unique()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:10.887079Z","iopub.execute_input":"2022-11-14T11:35:10.887426Z","iopub.status.idle":"2022-11-14T11:35:10.916558Z","shell.execute_reply.started":"2022-11-14T11:35:10.887388Z","shell.execute_reply":"2022-11-14T11:35:10.915318Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.jockey.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:10.918100Z","iopub.execute_input":"2022-11-14T11:35:10.918513Z","iopub.status.idle":"2022-11-14T11:35:11.300515Z","shell.execute_reply.started":"2022-11-14T11:35:10.918473Z","shell.execute_reply":"2022-11-14T11:35:11.298882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.position_at_finish.unique()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:11.301774Z","iopub.execute_input":"2022-11-14T11:35:11.302143Z","iopub.status.idle":"2022-11-14T11:35:11.332693Z","shell.execute_reply.started":"2022-11-14T11:35:11.302110Z","shell.execute_reply":"2022-11-14T11:35:11.328292Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Conclusions","metadata":{}},{"cell_type":"markdown","source":"We have checked unique values with df.nunique()","metadata":{}},{"cell_type":"markdown","source":"## Missing values","metadata":{}},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:11.334183Z","iopub.execute_input":"2022-11-14T11:35:11.334791Z","iopub.status.idle":"2022-11-14T11:35:12.491420Z","shell.execute_reply.started":"2022-11-14T11:35:11.334752Z","shell.execute_reply":"2022-11-14T11:35:12.490197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Conclusions","metadata":{}},{"cell_type":"markdown","source":"No missing values in dataframe.","metadata":{}},{"cell_type":"markdown","source":"## EDA","metadata":{}},{"cell_type":"code","source":"sns.countplot(data = df_start, x = 'track_id')\nplt.show()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:12.493167Z","iopub.execute_input":"2022-11-14T11:35:12.493515Z","iopub.status.idle":"2022-11-14T11:35:12.689280Z","shell.execute_reply.started":"2022-11-14T11:35:12.493484Z","shell.execute_reply":"2022-11-14T11:35:12.687971Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_start, x = 'race_number')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:12.690550Z","iopub.execute_input":"2022-11-14T11:35:12.691318Z","iopub.status.idle":"2022-11-14T11:35:12.934763Z","shell.execute_reply.started":"2022-11-14T11:35:12.691285Z","shell.execute_reply":"2022-11-14T11:35:12.933382Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_start, x = 'program_number')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:12.936549Z","iopub.execute_input":"2022-11-14T11:35:12.936962Z","iopub.status.idle":"2022-11-14T11:35:13.241323Z","shell.execute_reply.started":"2022-11-14T11:35:12.936906Z","shell.execute_reply":"2022-11-14T11:35:13.240089Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_start, x = 'weight_carried')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:13.243010Z","iopub.execute_input":"2022-11-14T11:35:13.243425Z","iopub.status.idle":"2022-11-14T11:35:13.630501Z","shell.execute_reply.started":"2022-11-14T11:35:13.243391Z","shell.execute_reply":"2022-11-14T11:35:13.628950Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start.describe()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:13.632186Z","iopub.execute_input":"2022-11-14T11:35:13.632532Z","iopub.status.idle":"2022-11-14T11:35:13.663824Z","shell.execute_reply.started":"2022-11-14T11:35:13.632501Z","shell.execute_reply":"2022-11-14T11:35:13.662375Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(df_start['weight_carried']);","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:13.665535Z","iopub.execute_input":"2022-11-14T11:35:13.665973Z","iopub.status.idle":"2022-11-14T11:35:13.860162Z","shell.execute_reply.started":"2022-11-14T11:35:13.665897Z","shell.execute_reply":"2022-11-14T11:35:13.858579Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_start, x = 'position_at_finish')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:13.863644Z","iopub.execute_input":"2022-11-14T11:35:13.863999Z","iopub.status.idle":"2022-11-14T11:35:14.097502Z","shell.execute_reply.started":"2022-11-14T11:35:13.863969Z","shell.execute_reply":"2022-11-14T11:35:14.096018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_race, x = 'distance_id')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:14.099152Z","iopub.execute_input":"2022-11-14T11:35:14.099527Z","iopub.status.idle":"2022-11-14T11:35:14.375817Z","shell.execute_reply.started":"2022-11-14T11:35:14.099454Z","shell.execute_reply":"2022-11-14T11:35:14.374530Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_race, x = 'course_type')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:14.377596Z","iopub.execute_input":"2022-11-14T11:35:14.377901Z","iopub.status.idle":"2022-11-14T11:35:14.536669Z","shell.execute_reply.started":"2022-11-14T11:35:14.377874Z","shell.execute_reply":"2022-11-14T11:35:14.535475Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_race, x = 'track_condition')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:14.538879Z","iopub.execute_input":"2022-11-14T11:35:14.539343Z","iopub.status.idle":"2022-11-14T11:35:14.721642Z","shell.execute_reply.started":"2022-11-14T11:35:14.539306Z","shell.execute_reply":"2022-11-14T11:35:14.720703Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.countplot(data = df_race, x = 'race_type')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:14.722992Z","iopub.execute_input":"2022-11-14T11:35:14.723282Z","iopub.status.idle":"2022-11-14T11:35:14.937226Z","shell.execute_reply.started":"2022-11-14T11:35:14.723254Z","shell.execute_reply":"2022-11-14T11:35:14.935397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_start.track_id.unique():\n    sns.countplot(data = df_start[df_start.track_id == t], x='race_number')\n    plt.title(t)\n    plt.show()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:14.938644Z","iopub.execute_input":"2022-11-14T11:35:14.939045Z","iopub.status.idle":"2022-11-14T11:35:15.604831Z","shell.execute_reply.started":"2022-11-14T11:35:14.939011Z","shell.execute_reply":"2022-11-14T11:35:15.603403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_start.track_id.unique():\n    sns.countplot(data = df_start[df_start.track_id == t], x='program_number')\n    plt.title(t)\n    plt.show()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:15.606570Z","iopub.execute_input":"2022-11-14T11:35:15.607003Z","iopub.status.idle":"2022-11-14T11:35:16.576031Z","shell.execute_reply.started":"2022-11-14T11:35:15.606965Z","shell.execute_reply":"2022-11-14T11:35:16.574079Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_start.track_id.unique():\n    sns.countplot(data = df_start[df_start.track_id == t], x='weight_carried')\n    plt.title(t)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:16.579420Z","iopub.execute_input":"2022-11-14T11:35:16.579884Z","iopub.status.idle":"2022-11-14T11:35:17.528057Z","shell.execute_reply.started":"2022-11-14T11:35:16.579838Z","shell.execute_reply":"2022-11-14T11:35:17.526814Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_start.track_id.unique():\n    sns.countplot(data = df_start[df_start.track_id == t], x='position_at_finish')\n    plt.title(t)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:17.529395Z","iopub.execute_input":"2022-11-14T11:35:17.529751Z","iopub.status.idle":"2022-11-14T11:35:18.231468Z","shell.execute_reply.started":"2022-11-14T11:35:17.529723Z","shell.execute_reply":"2022-11-14T11:35:18.230392Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_race.track_id.unique():\n    sns.countplot(data = df_race[df_race.track_id == t], x='distance_id')\n    plt.title(t)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:18.232872Z","iopub.execute_input":"2022-11-14T11:35:18.233315Z","iopub.status.idle":"2022-11-14T11:35:18.895981Z","shell.execute_reply.started":"2022-11-14T11:35:18.233290Z","shell.execute_reply":"2022-11-14T11:35:18.894992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_race.track_id.unique():\n    sns.countplot(data = df_race[df_race.track_id == t], x='course_type')\n    plt.title(t)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:18.897354Z","iopub.execute_input":"2022-11-14T11:35:18.897662Z","iopub.status.idle":"2022-11-14T11:35:19.357810Z","shell.execute_reply.started":"2022-11-14T11:35:18.897632Z","shell.execute_reply":"2022-11-14T11:35:19.357007Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_race.track_id.unique():\n    sns.countplot(data = df_race[df_race.track_id == t], x='track_condition')\n    plt.title(t)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:19.359262Z","iopub.execute_input":"2022-11-14T11:35:19.359805Z","iopub.status.idle":"2022-11-14T11:35:20.056958Z","shell.execute_reply.started":"2022-11-14T11:35:19.359774Z","shell.execute_reply":"2022-11-14T11:35:20.056075Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_race.track_id.unique():\n    sns.countplot(data = df_race[df_race.track_id == t], x='race_type')\n    plt.title(t)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:20.058495Z","iopub.execute_input":"2022-11-14T11:35:20.058995Z","iopub.status.idle":"2022-11-14T11:35:20.664547Z","shell.execute_reply.started":"2022-11-14T11:35:20.058962Z","shell.execute_reply":"2022-11-14T11:35:20.663058Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t in df_race.track_id.unique():\n    sns.countplot(data = df_race[df_race.track_id == t], x='purse')\n    plt.title(t)\n    plt.xticks(rotation=90)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:20.666538Z","iopub.execute_input":"2022-11-14T11:35:20.667305Z","iopub.status.idle":"2022-11-14T11:35:22.418953Z","shell.execute_reply.started":"2022-11-14T11:35:20.667260Z","shell.execute_reply":"2022-11-14T11:35:22.417481Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.course_type.unique():\n    sns.countplot(data = df_race[df_race.course_type == c], x='track_id')\n    plt.title(c)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:22.421000Z","iopub.execute_input":"2022-11-14T11:35:22.421407Z","iopub.status.idle":"2022-11-14T11:35:23.144557Z","shell.execute_reply.started":"2022-11-14T11:35:22.421372Z","shell.execute_reply":"2022-11-14T11:35:23.143770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.course_type.unique():\n    sns.countplot(data = df_race[df_race.course_type == c], x='race_number')\n    plt.title(c)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:23.145691Z","iopub.execute_input":"2022-11-14T11:35:23.146572Z","iopub.status.idle":"2022-11-14T11:35:24.307584Z","shell.execute_reply.started":"2022-11-14T11:35:23.146537Z","shell.execute_reply":"2022-11-14T11:35:24.306751Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.course_type.unique():\n    sns.countplot(data = df_race[df_race.course_type == c], x='track_condition')\n    plt.title(c)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:24.308770Z","iopub.execute_input":"2022-11-14T11:35:24.309275Z","iopub.status.idle":"2022-11-14T11:35:25.080617Z","shell.execute_reply.started":"2022-11-14T11:35:24.309242Z","shell.execute_reply":"2022-11-14T11:35:25.079555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.course_type.unique():\n    sns.countplot(data = df_race[df_race.course_type == c], x='race_type')\n    plt.title(c)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:25.081925Z","iopub.execute_input":"2022-11-14T11:35:25.082258Z","iopub.status.idle":"2022-11-14T11:35:25.941342Z","shell.execute_reply.started":"2022-11-14T11:35:25.082229Z","shell.execute_reply":"2022-11-14T11:35:25.940420Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.course_type.unique():\n    sns.countplot(data = df_race[df_race.course_type == c], x='purse')\n    plt.title(c)\n    plt.xticks(rotation=90)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:25.942705Z","iopub.execute_input":"2022-11-14T11:35:25.943045Z","iopub.status.idle":"2022-11-14T11:35:28.606900Z","shell.execute_reply.started":"2022-11-14T11:35:25.943013Z","shell.execute_reply":"2022-11-14T11:35:28.606144Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.race_type.unique():\n    sns.countplot(data = df_race[df_race.race_type == c], x='course_type')\n    plt.title(c)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:28.608196Z","iopub.execute_input":"2022-11-14T11:35:28.608660Z","iopub.status.idle":"2022-11-14T11:35:30.302880Z","shell.execute_reply.started":"2022-11-14T11:35:28.608630Z","shell.execute_reply":"2022-11-14T11:35:30.302081Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for c in df_race.race_type.unique():\n    sns.countplot(data = df_race[df_race.race_type == c], x='track_id')\n    plt.title(c)\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:30.304229Z","iopub.execute_input":"2022-11-14T11:35:30.304723Z","iopub.status.idle":"2022-11-14T11:35:31.866584Z","shell.execute_reply.started":"2022-11-14T11:35:30.304688Z","shell.execute_reply":"2022-11-14T11:35:31.865482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t  in df_race.track_id.unique():\n    sns.countplot(data = df_race[df_race.track_id == t], x='course_type', hue=\"distance_id\")\n    plt.title(t)\n    plt.legend(loc='right')\n    plt.show()","metadata":{"scrolled":true,"execution":{"iopub.status.busy":"2022-11-14T11:35:31.868075Z","iopub.execute_input":"2022-11-14T11:35:31.868501Z","iopub.status.idle":"2022-11-14T11:35:32.912798Z","shell.execute_reply.started":"2022-11-14T11:35:31.868462Z","shell.execute_reply":"2022-11-14T11:35:32.911455Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for t  in df_race.track_condition.unique():\n    sns.countplot(data = df_race[df_race.track_condition == t], x='course_type', hue=\"track_id\")\n    plt.title(t)\n    plt.legend(loc='right')\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:32.914255Z","iopub.execute_input":"2022-11-14T11:35:32.915628Z","iopub.status.idle":"2022-11-14T11:35:34.058620Z","shell.execute_reply.started":"2022-11-14T11:35:32.915555Z","shell.execute_reply":"2022-11-14T11:35:34.057824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### race_date","metadata":{}},{"cell_type":"code","source":"print('Race date period: ', df['race_date'].min(), '-', df_start['race_date'].max())","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:34.059800Z","iopub.execute_input":"2022-11-14T11:35:34.060340Z","iopub.status.idle":"2022-11-14T11:35:34.077771Z","shell.execute_reply.started":"2022-11-14T11:35:34.060307Z","shell.execute_reply":"2022-11-14T11:35:34.076104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start.hist('race_date', bins = 50);","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:34.079246Z","iopub.execute_input":"2022-11-14T11:35:34.079787Z","iopub.status.idle":"2022-11-14T11:35:34.471500Z","shell.execute_reply.started":"2022-11-14T11:35:34.079751Z","shell.execute_reply":"2022-11-14T11:35:34.470008Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.boxplot(data = df_race, \n            y = df_race['distance_id']);","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:34.473907Z","iopub.execute_input":"2022-11-14T11:35:34.474730Z","iopub.status.idle":"2022-11-14T11:35:34.617091Z","shell.execute_reply.started":"2022-11-14T11:35:34.474664Z","shell.execute_reply":"2022-11-14T11:35:34.616157Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(7,5), dpi= 80)\nsns.distplot(df_race['race_number'], hist=True, kde=True,\n             bins=int(14), color = 'red', \n             hist_kws={'edgecolor':'red'},\n             kde_kws={'linewidth': 4})\nplt.title('Race number distribution')\nplt.ylabel('Distribution');","metadata":{"execution":{"iopub.status.busy":"2022-11-14T11:35:34.618489Z","iopub.execute_input":"2022-11-14T11:35:34.618984Z","iopub.status.idle":"2022-11-14T11:35:34.894184Z","shell.execute_reply.started":"2022-11-14T11:35:34.618953Z","shell.execute_reply":"2022-11-14T11:35:34.892963Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Thank you","metadata":{}}]}