{"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":"## Idea from here\n- https://www.kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/discussion/308635","metadata":{}},{"cell_type":"markdown","source":"## ","metadata":{}},{"cell_type":"code","source":"import os\nimport numpy as np\nimport pandas as pd\nfrom sklearn.preprocessing import LabelEncoder\n\n\nimport cudf\nimport cuml\nprint('RAPIDS version',cudf.__version__)","metadata":{"execution":{"iopub.status.busy":"2022-04-12T00:12:58.234412Z","iopub.execute_input":"2022-04-12T00:12:58.235142Z","iopub.status.idle":"2022-04-12T00:13:02.233643Z","shell.execute_reply.started":"2022-04-12T00:12:58.235053Z","shell.execute_reply":"2022-04-12T00:13:02.232069Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"INPUT_DIR = '../input/h-and-m-personalized-fashion-recommendations/'\nOUTPUT_DIR = 'dataset/'\nos.makedirs(OUTPUT_DIR, exist_ok=True)\n\ntransactions = cudf.read_csv(INPUT_DIR + 'transactions_train.csv')\ntransactions['customer_id'] = transactions['customer_id'].str[-16:].str.hex_to_int().astype('int64')\ntransactions['article_id'] = transactions.article_id.astype('int32')\ntransactions.t_dat = cudf.to_datetime(transactions.t_dat)\ntransactions['price'] = transactions['price'].astype('float32')\ntransactions['sales_channel_id'] = transactions['sales_channel_id'].astype('int8')\nprint( transactions.shape )\ntransactions.to_parquet(OUTPUT_DIR+'transactions.pqt',index=False)","metadata":{"execution":{"iopub.status.busy":"2022-04-12T00:14:13.638929Z","iopub.execute_input":"2022-04-12T00:14:13.639531Z","iopub.status.idle":"2022-04-12T00:14:54.736909Z","shell.execute_reply.started":"2022-04-12T00:14:13.639492Z","shell.execute_reply":"2022-04-12T00:14:54.736109Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"customers = cudf.read_csv(INPUT_DIR + 'customers.csv')\ncustomers['customer_id'] = customers['customer_id'].str[-16:].str.hex_to_int().astype('int64')\ncustomers.to_parquet(OUTPUT_DIR+'customers.pqt',index=False)","metadata":{"execution":{"iopub.status.busy":"2022-04-12T00:16:26.867959Z","iopub.execute_input":"2022-04-12T00:16:26.868524Z","iopub.status.idle":"2022-04-12T00:16:29.759361Z","shell.execute_reply.started":"2022-04-12T00:16:26.868484Z","shell.execute_reply":"2022-04-12T00:16:29.758622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}