{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-09-08T08:34:17.971883Z","iopub.execute_input":"2022-09-08T08:34:17.972577Z","iopub.status.idle":"2022-09-08T08:34:17.985655Z","shell.execute_reply.started":"2022-09-08T08:34:17.972506Z","shell.execute_reply":"2022-09-08T08:34:17.984185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:17.988120Z","iopub.execute_input":"2022-09-08T08:34:17.988792Z","iopub.status.idle":"2022-09-08T08:34:19.235226Z","shell.execute_reply.started":"2022-09-08T08:34:17.988754Z","shell.execute_reply":"2022-09-08T08:34:19.234030Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_tracking_table.csv')\ndf_start = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_start_table.csv')\ndf_race = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_race_table.csv')\ndf_2019 = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_2019_complete.csv')","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:19.237151Z","iopub.execute_input":"2022-09-08T08:34:19.237540Z","iopub.status.idle":"2022-09-08T08:34:37.483155Z","shell.execute_reply.started":"2022-09-08T08:34:19.237507Z","shell.execute_reply":"2022-09-08T08:34:37.482325Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking.columns","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:37.484531Z","iopub.execute_input":"2022-09-08T08:34:37.484836Z","iopub.status.idle":"2022-09-08T08:34:37.495405Z","shell.execute_reply.started":"2022-09-08T08:34:37.484809Z","shell.execute_reply":"2022-09-08T08:34:37.493723Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start.columns","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:37.498142Z","iopub.execute_input":"2022-09-08T08:34:37.498530Z","iopub.status.idle":"2022-09-08T08:34:37.510877Z","shell.execute_reply.started":"2022-09-08T08:34:37.498502Z","shell.execute_reply":"2022-09-08T08:34:37.509431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_race.columns","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:37.513049Z","iopub.execute_input":"2022-09-08T08:34:37.513731Z","iopub.status.idle":"2022-09-08T08:34:37.524005Z","shell.execute_reply.started":"2022-09-08T08:34:37.513688Z","shell.execute_reply":"2022-09-08T08:34:37.522987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_2019.columns","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:37.525020Z","iopub.execute_input":"2022-09-08T08:34:37.525319Z","iopub.status.idle":"2022-09-08T08:34:37.538255Z","shell.execute_reply.started":"2022-09-08T08:34:37.525290Z","shell.execute_reply":"2022-09-08T08:34:37.537487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking.info()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:37.539536Z","iopub.execute_input":"2022-09-08T08:34:37.539858Z","iopub.status.idle":"2022-09-08T08:34:37.574927Z","shell.execute_reply.started":"2022-09-08T08:34:37.539831Z","shell.execute_reply":"2022-09-08T08:34:37.573280Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:37.577933Z","iopub.execute_input":"2022-09-08T08:34:37.579236Z","iopub.status.idle":"2022-09-08T08:34:38.142484Z","shell.execute_reply.started":"2022-09-08T08:34:37.579185Z","shell.execute_reply":"2022-09-08T08:34:38.140901Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:38.144181Z","iopub.execute_input":"2022-09-08T08:34:38.144566Z","iopub.status.idle":"2022-09-08T08:34:42.995887Z","shell.execute_reply.started":"2022-09-08T08:34:38.144532Z","shell.execute_reply":"2022-09-08T08:34:42.994889Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking.head(10)","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:42.999935Z","iopub.execute_input":"2022-09-08T08:34:43.000232Z","iopub.status.idle":"2022-09-08T08:34:43.020184Z","shell.execute_reply.started":"2022-09-08T08:34:43.000203Z","shell.execute_reply":"2022-09-08T08:34:43.018965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['track_id'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:43.022653Z","iopub.execute_input":"2022-09-08T08:34:43.023572Z","iopub.status.idle":"2022-09-08T08:34:43.284327Z","shell.execute_reply.started":"2022-09-08T08:34:43.023511Z","shell.execute_reply":"2022-09-08T08:34:43.282625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['race_date'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:43.286804Z","iopub.execute_input":"2022-09-08T08:34:43.287799Z","iopub.status.idle":"2022-09-08T08:34:43.544996Z","shell.execute_reply.started":"2022-09-08T08:34:43.287695Z","shell.execute_reply":"2022-09-08T08:34:43.543702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import datetime\nimport matplotlib.dates","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:43.547596Z","iopub.execute_input":"2022-09-08T08:34:43.549816Z","iopub.status.idle":"2022-09-08T08:34:43.556090Z","shell.execute_reply.started":"2022-09-08T08:34:43.549762Z","shell.execute_reply":"2022-09-08T08:34:43.554593Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport pandas as pd","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:43.557940Z","iopub.execute_input":"2022-09-08T08:34:43.558979Z","iopub.status.idle":"2022-09-08T08:34:43.567792Z","shell.execute_reply.started":"2022-09-08T08:34:43.558939Z","shell.execute_reply":"2022-09-08T08:34:43.567028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_tracking_table.csv')\n#df_tracking['race_date']=pd.to_datetime(df_tracking['race_date'])","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:43.569278Z","iopub.execute_input":"2022-09-08T08:34:43.569810Z","iopub.status.idle":"2022-09-08T08:34:46.514242Z","shell.execute_reply.started":"2022-09-08T08:34:43.569777Z","shell.execute_reply":"2022-09-08T08:34:46.513045Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['year'] = df_tracking['race_date'].apply(lambda x:int(x.split('-')[0]))\ndf_tracking['year']","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:46.515715Z","iopub.execute_input":"2022-09-08T08:34:46.516234Z","iopub.status.idle":"2022-09-08T08:34:49.852499Z","shell.execute_reply.started":"2022-09-08T08:34:46.516202Z","shell.execute_reply":"2022-09-08T08:34:49.851876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['year'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:49.853678Z","iopub.execute_input":"2022-09-08T08:34:49.854076Z","iopub.status.idle":"2022-09-08T08:34:49.901532Z","shell.execute_reply.started":"2022-09-08T08:34:49.854049Z","shell.execute_reply":"2022-09-08T08:34:49.900877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['month'] = df_tracking['race_date'].apply(lambda x: int(x.split('-')[1]))\ndf_tracking['month']","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:49.902663Z","iopub.execute_input":"2022-09-08T08:34:49.903055Z","iopub.status.idle":"2022-09-08T08:34:53.135725Z","shell.execute_reply.started":"2022-09-08T08:34:49.903029Z","shell.execute_reply":"2022-09-08T08:34:53.134236Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['month'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:53.137191Z","iopub.execute_input":"2022-09-08T08:34:53.137577Z","iopub.status.idle":"2022-09-08T08:34:53.189579Z","shell.execute_reply.started":"2022-09-08T08:34:53.137544Z","shell.execute_reply":"2022-09-08T08:34:53.187967Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tracking['month'].value_counts().plot(kind='bar', figsize=(16,10))","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:53.191037Z","iopub.execute_input":"2022-09-08T08:34:53.191333Z","iopub.status.idle":"2022-09-08T08:34:53.517556Z","shell.execute_reply.started":"2022-09-08T08:34:53.191307Z","shell.execute_reply":"2022-09-08T08:34:53.515831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install folium","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:34:53.519519Z","iopub.execute_input":"2022-09-08T08:34:53.519869Z","iopub.status.idle":"2022-09-08T08:35:04.388337Z","shell.execute_reply.started":"2022-09-08T08:34:53.519838Z","shell.execute_reply":"2022-09-08T08:35:04.387137Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Import the folium library\nimport folium\n\n# Build the default map for a specific location\nmap = folium.Map(location=[40.672243,-73.827903])\nmap","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:46:51.033151Z","iopub.execute_input":"2022-09-08T08:46:51.033736Z","iopub.status.idle":"2022-09-08T08:46:51.057164Z","shell.execute_reply.started":"2022-09-08T08:46:51.033699Z","shell.execute_reply":"2022-09-08T08:46:51.055929Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Dataset 2**","metadata":{}},{"cell_type":"code","source":"df_start = pd.read_csv('/kaggle/input/big-data-derby-2022/nyra_start_table.csv')\ndf_start","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:53:52.705861Z","iopub.execute_input":"2022-09-08T08:53:52.707156Z","iopub.status.idle":"2022-09-08T08:53:52.758875Z","shell.execute_reply.started":"2022-09-08T08:53:52.707111Z","shell.execute_reply":"2022-09-08T08:53:52.757589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start.info()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:54:58.951912Z","iopub.execute_input":"2022-09-08T08:54:58.952327Z","iopub.status.idle":"2022-09-08T08:54:58.970350Z","shell.execute_reply.started":"2022-09-08T08:54:58.952295Z","shell.execute_reply":"2022-09-08T08:54:58.969172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start.describe(include='all')","metadata":{"execution":{"iopub.status.busy":"2022-09-08T08:55:19.147925Z","iopub.execute_input":"2022-09-08T08:55:19.148360Z","iopub.status.idle":"2022-09-08T08:55:19.193210Z","shell.execute_reply.started":"2022-09-08T08:55:19.148325Z","shell.execute_reply":"2022-09-08T08:55:19.191742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-09-08T09:04:31.787835Z","iopub.execute_input":"2022-09-08T09:04:31.788271Z","iopub.status.idle":"2022-09-08T09:04:31.803020Z","shell.execute_reply.started":"2022-09-08T09:04:31.788234Z","shell.execute_reply":"2022-09-08T09:04:31.801430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start['year'] = df_start['race_date'].apply(lambda x:int(x.split('-')[0]))\ndf_start['year']","metadata":{"execution":{"iopub.status.busy":"2022-09-08T09:06:12.612540Z","iopub.execute_input":"2022-09-08T09:06:12.612955Z","iopub.status.idle":"2022-09-08T09:06:12.635198Z","shell.execute_reply.started":"2022-09-08T09:06:12.612920Z","shell.execute_reply":"2022-09-08T09:06:12.634187Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start['year']","metadata":{"execution":{"iopub.status.busy":"2022-09-08T09:06:27.101678Z","iopub.execute_input":"2022-09-08T09:06:27.102069Z","iopub.status.idle":"2022-09-08T09:06:27.111874Z","shell.execute_reply.started":"2022-09-08T09:06:27.102037Z","shell.execute_reply":"2022-09-08T09:06:27.110757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start['month'] = df_start['race_date'].apply(lambda x:int(x.split('-')[1]))\ndf_start['month']","metadata":{"execution":{"iopub.status.busy":"2022-09-08T09:07:12.864380Z","iopub.execute_input":"2022-09-08T09:07:12.864762Z","iopub.status.idle":"2022-09-08T09:07:12.886015Z","shell.execute_reply.started":"2022-09-08T09:07:12.864730Z","shell.execute_reply":"2022-09-08T09:07:12.884729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start['month'].value_counts().plot(kind='bar',figsize=(16,8))","metadata":{"execution":{"iopub.status.busy":"2022-09-08T09:08:00.535230Z","iopub.execute_input":"2022-09-08T09:08:00.535648Z","iopub.status.idle":"2022-09-08T09:08:00.778405Z","shell.execute_reply.started":"2022-09-08T09:08:00.535612Z","shell.execute_reply":"2022-09-08T09:08:00.777305Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_start['jockey'].value_counts(10).plot(kind='bar', figsize=(16,7))","metadata":{"execution":{"iopub.status.busy":"2022-09-08T09:27:48.414127Z","iopub.execute_input":"2022-09-08T09:27:48.415651Z","iopub.status.idle":"2022-09-08T09:27:50.608725Z","shell.execute_reply.started":"2022-09-08T09:27:48.415595Z","shell.execute_reply":"2022-09-08T09:27:50.607562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}