{"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 numpy as np\ndataset = pd.read_csv('../input/big-data-derby-2022/nyra_2019_complete.csv')\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-08-31T07:41:30.159155Z","iopub.execute_input":"2022-08-31T07:41:30.160012Z","iopub.status.idle":"2022-08-31T07:41:45.280162Z","shell.execute_reply.started":"2022-08-31T07:41:30.159902Z","shell.execute_reply":"2022-08-31T07:41:45.279091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dataset\n","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:42:31.902549Z","iopub.execute_input":"2022-08-31T07:42:31.903154Z","iopub.status.idle":"2022-08-31T07:42:31.949250Z","shell.execute_reply.started":"2022-08-31T07:42:31.903102Z","shell.execute_reply":"2022-08-31T07:42:31.948078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Format change to be compilable to datetime\n\ndataset[\"race_date\"] = pd.to_datetime(dataset[\"race_date\"])\ndataset[\"race_date\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:42:37.150837Z","iopub.execute_input":"2022-08-31T07:42:37.151253Z","iopub.status.idle":"2022-08-31T07:42:38.164649Z","shell.execute_reply.started":"2022-08-31T07:42:37.151219Z","shell.execute_reply":"2022-08-31T07:42:38.163477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#day name\n\ndataset[\"day\"] = dataset[\"race_date\"].dt.day_name()\ndataset[\"day\"]","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:42:44.368599Z","iopub.execute_input":"2022-08-31T07:42:44.369416Z","iopub.status.idle":"2022-08-31T07:42:46.031640Z","shell.execute_reply.started":"2022-08-31T07:42:44.369365Z","shell.execute_reply":"2022-08-31T07:42:46.030306Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"race_time = dataset.post_time.unique()\nprint(race_time)","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:50:13.430281Z","iopub.execute_input":"2022-08-31T07:50:13.430716Z","iopub.status.idle":"2022-08-31T07:50:13.469959Z","shell.execute_reply.started":"2022-08-31T07:50:13.430683Z","shell.execute_reply":"2022-08-31T07:50:13.468754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#data sorted to see racing hours(earlieast race at 11:30 am, last race at 8:00 pm)\n\nrace_time.sort()\nrace_time","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:50:40.055258Z","iopub.execute_input":"2022-08-31T07:50:40.056433Z","iopub.status.idle":"2022-08-31T07:50:40.067117Z","shell.execute_reply.started":"2022-08-31T07:50:40.056375Z","shell.execute_reply":"2022-08-31T07:50:40.065812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# list of conditions\nconditions = [\n    (dataset['post_time'] == 1130),\n    (dataset['post_time'] > 1130) & (dataset['post_time'] <= 1259),\n    (dataset['post_time'] >= 100) & (dataset['post_time'] <= 459),\n    (dataset['post_time'] >= 501) & (dataset['post_time'] <= 728),\n    (dataset['post_time'] == 800)\n    ]\n\n# list od day periods\nvalues = ['earliest', 'ealry mid-day', 'mid-day', 'afternoon' , 'last']\n\ndataset['day_period'] = np.select(conditions, values)\n\n# display updated DataFrame\ndataset.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-31T07:59:35.925872Z","iopub.execute_input":"2022-08-31T07:59:35.926368Z","iopub.status.idle":"2022-08-31T07:59:37.344649Z","shell.execute_reply.started":"2022-08-31T07:59:35.926331Z","shell.execute_reply":"2022-08-31T07:59:37.343336Z"},"trusted":true},"execution_count":null,"outputs":[]}]}