{"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","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:26:27.591247Z","iopub.execute_input":"2022-02-12T14:26:27.591796Z","iopub.status.idle":"2022-02-12T14:26:27.59633Z","shell.execute_reply.started":"2022-02-12T14:26:27.591745Z","shell.execute_reply":"2022-02-12T14:26:27.595513Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran = pd.read_csv(\"/kaggle/input/h-and-m-personalized-fashion-recommendations/transactions_train.csv\")","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-02-12T14:27:17.84393Z","iopub.execute_input":"2022-02-12T14:27:17.844386Z","iopub.status.idle":"2022-02-12T14:28:24.276256Z","shell.execute_reply.started":"2022-02-12T14:27:17.844353Z","shell.execute_reply":"2022-02-12T14:28:24.275246Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran.head()","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:29:02.620896Z","iopub.execute_input":"2022-02-12T14:29:02.621186Z","iopub.status.idle":"2022-02-12T14:29:02.643689Z","shell.execute_reply.started":"2022-02-12T14:29:02.621156Z","shell.execute_reply":"2022-02-12T14:29:02.6428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:29:10.003082Z","iopub.execute_input":"2022-02-12T14:29:10.003369Z","iopub.status.idle":"2022-02-12T14:29:10.009776Z","shell.execute_reply.started":"2022-02-12T14:29:10.003337Z","shell.execute_reply":"2022-02-12T14:29:10.008663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran[\"t_dat\"] = pd.to_datetime(df_tran[\"t_dat\"])","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:29:51.962362Z","iopub.execute_input":"2022-02-12T14:29:51.962914Z","iopub.status.idle":"2022-02-12T14:29:57.677478Z","shell.execute_reply.started":"2022-02-12T14:29:51.962855Z","shell.execute_reply":"2022-02-12T14:29:57.676526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran.t_dat.max(), df_tran.t_dat.min()","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:34:09.904368Z","iopub.execute_input":"2022-02-12T14:34:09.904671Z","iopub.status.idle":"2022-02-12T14:34:10.175319Z","shell.execute_reply.started":"2022-02-12T14:34:09.90464Z","shell.execute_reply":"2022-02-12T14:34:10.174224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cond_max = df_tran[\"t_dat\"] < pd.to_datetime(\"2019-1-1\")\ndf_tran_2018 = df_tran[cond_max]\ndf_tran_2018.t_dat.max(), df_tran_2018.t_dat.min()","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:34:39.872766Z","iopub.execute_input":"2022-02-12T14:34:39.873082Z","iopub.status.idle":"2022-02-12T14:34:40.465042Z","shell.execute_reply.started":"2022-02-12T14:34:39.873048Z","shell.execute_reply":"2022-02-12T14:34:40.46419Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cond_min = pd.to_datetime(\"2019-1-1\") <= df_tran[\"t_dat\"] \ncond_max = df_tran[\"t_dat\"] < pd.to_datetime(\"2020-1-1\")\ndf_tran_2019 = df_tran[cond_min & cond_max]\n\ndf_tran_2019.t_dat.max(), df_tran_2019.t_dat.min()","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:34:40.508229Z","iopub.execute_input":"2022-02-12T14:34:40.508547Z","iopub.status.idle":"2022-02-12T14:34:42.272258Z","shell.execute_reply.started":"2022-02-12T14:34:40.508513Z","shell.execute_reply":"2022-02-12T14:34:42.271335Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cond_min = pd.to_datetime(\"2020-1-1\") <= df_tran[\"t_dat\"] \ndf_tran_2020 = df_tran[cond_min]\n\ndf_tran_2020.t_dat.max(), df_tran_2020.t_dat.min()","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:35:16.161557Z","iopub.execute_input":"2022-02-12T14:35:16.161821Z","iopub.status.idle":"2022-02-12T14:35:17.116821Z","shell.execute_reply.started":"2022-02-12T14:35:16.161793Z","shell.execute_reply":"2022-02-12T14:35:17.115858Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran_2018.shape , df_tran_2019.shape, df_tran_2020.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:35:36.182858Z","iopub.execute_input":"2022-02-12T14:35:36.183147Z","iopub.status.idle":"2022-02-12T14:35:36.18984Z","shell.execute_reply.started":"2022-02-12T14:35:36.183109Z","shell.execute_reply":"2022-02-12T14:35:36.188954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_tran_2018.to_csv(\"transactions_train_2018.csv\", index=None)\ndf_tran_2019.to_csv(\"transactions_train_2019.csv\", index=None)\ndf_tran_2020.to_csv(\"transactions_train_2020.csv\", index=None)","metadata":{"execution":{"iopub.status.busy":"2022-02-12T14:37:31.238501Z","iopub.execute_input":"2022-02-12T14:37:31.239317Z","iopub.status.idle":"2022-02-12T14:45:06.911066Z","shell.execute_reply.started":"2022-02-12T14:37:31.239255Z","shell.execute_reply":"2022-02-12T14:45:06.909761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}