{"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 numpy as np\nimport pandas as pd","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-11-08T06:21:13.652468Z","iopub.execute_input":"2021-11-08T06:21:13.652850Z","iopub.status.idle":"2021-11-08T06:21:13.680973Z","shell.execute_reply.started":"2021-11-08T06:21:13.652746Z","shell.execute_reply":"2021-11-08T06:21:13.679983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## load data (timestamp / Asset_ID  / Target )","metadata":{}},{"cell_type":"code","source":"train = pd.read_csv('/kaggle/input/g-research-crypto-forecasting/train.csv', \n                 usecols=['Target', 'Asset_ID','timestamp'], dtype={'Asset_ID': 'int8'})\nprint(train.info())\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T06:21:13.682708Z","iopub.execute_input":"2021-11-08T06:21:13.683437Z","iopub.status.idle":"2021-11-08T06:22:01.416023Z","shell.execute_reply.started":"2021-11-08T06:21:13.683389Z","shell.execute_reply":"2021-11-08T06:22:01.415055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# convert Timestamp => DateTime by second ","metadata":{}},{"cell_type":"markdown","source":"### unit \n\nstr, ***default ‘ns’***\n\nThe unit of the arg (D,s,ms,us,ns) denote the unit, which is an integer or float number. \n\nThis will be based off the origin. Example, with unit=’ms’ and origin=’unix’ (the default), \n\nthis would calculate the number of milliseconds to the unix epoch start.","metadata":{}},{"cell_type":"code","source":"train['datetime'] = pd.to_datetime(train['timestamp'], unit='s')\nprint(train.info())\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T06:22:01.417949Z","iopub.execute_input":"2021-11-08T06:22:01.418312Z","iopub.status.idle":"2021-11-08T06:22:03.080724Z","shell.execute_reply.started":"2021-11-08T06:22:01.418266Z","shell.execute_reply":"2021-11-08T06:22:03.079774Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# to index  and delete previous column","metadata":{}},{"cell_type":"code","source":"train = train.set_index('datetime').drop('timestamp', axis=1)\nprint(train.info())\ntrain.head()","metadata":{"execution":{"iopub.status.busy":"2021-11-08T06:22:03.082186Z","iopub.execute_input":"2021-11-08T06:22:03.082648Z","iopub.status.idle":"2021-11-08T06:22:03.976416Z","shell.execute_reply.started":"2021-11-08T06:22:03.082598Z","shell.execute_reply":"2021-11-08T06:22:03.975469Z"},"trusted":true},"execution_count":null,"outputs":[]}]}