{"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 pandas as pd\nimport matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-09-23T16:49:12.973406Z","iopub.execute_input":"2022-09-23T16:49:12.974135Z","iopub.status.idle":"2022-09-23T16:49:13.007009Z","shell.execute_reply.started":"2022-09-23T16:49:12.973984Z","shell.execute_reply":"2022-09-23T16:49:13.005872Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"start_table_df = pd.read_csv('../input/big-data-derby-2022/nyra_start_table.csv')\nstart_table_df.columns = ['track_id', 'race_date', 'race_number', 'program_number', 'weight_carried', 'jockey', 'odds', 'position_at_finish']\nstart_table_df['odds'] = start_table_df['odds']/100\n#start_table_df.head(20)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-09-23T17:59:35.856041Z","iopub.execute_input":"2022-09-23T17:59:35.856454Z","iopub.status.idle":"2022-09-23T17:59:35.895492Z","shell.execute_reply.started":"2022-09-23T17:59:35.856423Z","shell.execute_reply":"2022-09-23T17:59:35.894532Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#start_table_df.info()","metadata":{"execution":{"iopub.status.busy":"2022-09-23T18:06:43.960450Z","iopub.execute_input":"2022-09-23T18:06:43.960837Z","iopub.status.idle":"2022-09-23T18:06:43.978132Z","shell.execute_reply.started":"2022-09-23T18:06:43.960805Z","shell.execute_reply":"2022-09-23T18:06:43.976748Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race_table_df = pd.read_csv('../input/big-data-derby-2022/nyra_race_table.csv')\n#race_table_df.head(20)","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-09-23T18:00:52.330175Z","iopub.execute_input":"2022-09-23T18:00:52.330556Z","iopub.status.idle":"2022-09-23T18:00:52.356030Z","shell.execute_reply.started":"2022-09-23T18:00:52.330527Z","shell.execute_reply":"2022-09-23T18:00:52.354933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Total number of races","metadata":{}},{"cell_type":"code","source":"race_table_df.groupby(['race_date'])['race_number'].count().sum()","metadata":{"execution":{"iopub.status.busy":"2022-09-23T18:09:37.520630Z","iopub.execute_input":"2022-09-23T18:09:37.521153Z","iopub.status.idle":"2022-09-23T18:09:37.532463Z","shell.execute_reply.started":"2022-09-23T18:09:37.521113Z","shell.execute_reply":"2022-09-23T18:09:37.531093Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Number of races each day","metadata":{}},{"cell_type":"code","source":"race_table_df.groupby(['race_date'])['race_number'].count()","metadata":{"execution":{"iopub.status.busy":"2022-09-23T18:02:30.645483Z","iopub.execute_input":"2022-09-23T18:02:30.645853Z","iopub.status.idle":"2022-09-23T18:02:30.655687Z","shell.execute_reply.started":"2022-09-23T18:02:30.645823Z","shell.execute_reply":"2022-09-23T18:02:30.654518Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Number of races for each track","metadata":{}},{"cell_type":"code","source":"plt.bar(x = race_table_df['track_id'].value_counts().index, height = race_table_df['track_id'].value_counts())","metadata":{"execution":{"iopub.status.busy":"2022-09-23T18:13:02.030102Z","iopub.execute_input":"2022-09-23T18:13:02.030549Z","iopub.status.idle":"2022-09-23T18:13:02.227076Z","shell.execute_reply.started":"2022-09-23T18:13:02.030515Z","shell.execute_reply":"2022-09-23T18:13:02.225975Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#### Winner for every race","metadata":{}},{"cell_type":"code","source":"start_table_df[start_table_df['position_at_finish'] == 1]\n# since, we are returned 2003 rows while the number of rows are 2000. We might have the case of tie in few matches.","metadata":{"execution":{"iopub.status.busy":"2022-09-23T18:13:43.900857Z","iopub.execute_input":"2022-09-23T18:13:43.901303Z","iopub.status.idle":"2022-09-23T18:13:43.924400Z","shell.execute_reply.started":"2022-09-23T18:13:43.901266Z","shell.execute_reply":"2022-09-23T18:13:43.923227Z"},"trusted":true},"execution_count":null,"outputs":[]}]}