{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-05-31T10:12:23.419521Z","iopub.execute_input":"2022-05-31T10:12:23.42006Z","iopub.status.idle":"2022-05-31T10:12:23.451559Z","shell.execute_reply.started":"2022-05-31T10:12:23.419959Z","shell.execute_reply":"2022-05-31T10:12:23.450848Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import dask.dataframe as dd\nimport gc","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:23.487616Z","iopub.execute_input":"2022-05-31T10:12:23.488206Z","iopub.status.idle":"2022-05-31T10:12:24.286963Z","shell.execute_reply.started":"2022-05-31T10:12:23.48817Z","shell.execute_reply":"2022-05-31T10:12:24.285961Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.read_csv('../input/amex-default-prediction/test_data.csv', nrows=10)","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:24.288509Z","iopub.execute_input":"2022-05-31T10:12:24.288921Z","iopub.status.idle":"2022-05-31T10:12:24.318689Z","shell.execute_reply.started":"2022-05-31T10:12:24.288857Z","shell.execute_reply":"2022-05-31T10:12:24.3176Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dtype_dict = {}","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:24.320005Z","iopub.execute_input":"2022-05-31T10:12:24.320373Z","iopub.status.idle":"2022-05-31T10:12:24.326846Z","shell.execute_reply.started":"2022-05-31T10:12:24.320342Z","shell.execute_reply":"2022-05-31T10:12:24.32587Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cat_cols = ['B_30', 'B_38', 'D_114', 'D_116', 'D_117', 'D_120', 'D_126', 'D_63', 'D_64', 'D_66', 'D_68']\nfor col in cat_cols:\n    if test_df[col].dtype == \"float64\":\n        dtype_dict[col] = \"int8\" # category to \n    else:\n        dtype_dict[col] = str","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:24.328819Z","iopub.execute_input":"2022-05-31T10:12:24.329252Z","iopub.status.idle":"2022-05-31T10:12:24.340655Z","shell.execute_reply.started":"2022-05-31T10:12:24.329209Z","shell.execute_reply":"2022-05-31T10:12:24.339716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in test_df.columns:\n    \n    if test_df[col].dtype == \"float64\":\n        dtype_dict[col] = \"float32\"","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:24.34299Z","iopub.execute_input":"2022-05-31T10:12:24.34347Z","iopub.status.idle":"2022-05-31T10:12:24.497095Z","shell.execute_reply.started":"2022-05-31T10:12:24.343423Z","shell.execute_reply":"2022-05-31T10:12:24.496086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_df = pd.read_csv('../input/amex-default-prediction/train_data.csv', chunksize=100000)","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:24.498732Z","iopub.execute_input":"2022-05-31T10:12:24.499162Z","iopub.status.idle":"2022-05-31T10:12:24.515121Z","shell.execute_reply.started":"2022-05-31T10:12:24.499118Z","shell.execute_reply":"2022-05-31T10:12:24.514057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for index, row in enumerate(train_df):\n    row = row.astype(dtype_dict)\n    row['customer_ID'] = row['customer_ID'].astype('|S')\n    row['S_2'] = row['S_2'].astype('datetime64[ns]')\n    row.to_parquet(f'train_file_{index+1}.pqt', index=False)\n    del(row)\n    gc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:12:24.516494Z","iopub.execute_input":"2022-05-31T10:12:24.517039Z","iopub.status.idle":"2022-05-31T10:19:27.081406Z","shell.execute_reply.started":"2022-05-31T10:12:24.517007Z","shell.execute_reply":"2022-05-31T10:19:27.080308Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del(train_df)","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:21:04.380488Z","iopub.execute_input":"2022-05-31T10:21:04.380981Z","iopub.status.idle":"2022-05-31T10:21:04.386087Z","shell.execute_reply.started":"2022-05-31T10:21:04.380939Z","shell.execute_reply":"2022-05-31T10:21:04.384864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"gc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:22:47.241052Z","iopub.execute_input":"2022-05-31T10:22:47.241499Z","iopub.status.idle":"2022-05-31T10:22:47.391962Z","shell.execute_reply.started":"2022-05-31T10:22:47.241459Z","shell.execute_reply":"2022-05-31T10:22:47.390831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.read_csv('../input/amex-default-prediction/test_data.csv', chunksize=100000)","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:24:45.958805Z","iopub.execute_input":"2022-05-31T10:24:45.95925Z","iopub.status.idle":"2022-05-31T10:24:45.987604Z","shell.execute_reply.started":"2022-05-31T10:24:45.959203Z","shell.execute_reply":"2022-05-31T10:24:45.98686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for index, row in enumerate(test_df):\n    row = row.astype(dtype_dict)\n    row['customer_ID'] = row['customer_ID'].astype('|S')\n    row['S_2'] = row['S_2'].astype('datetime64[ns]')\n    row.to_parquet(f'test_file_{index+1}.pqt', index=False)\n    del(row)\n    gc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-05-31T10:24:54.229837Z","iopub.execute_input":"2022-05-31T10:24:54.230271Z","iopub.status.idle":"2022-05-31T10:39:34.662185Z","shell.execute_reply.started":"2022-05-31T10:24:54.230235Z","shell.execute_reply":"2022-05-31T10:39:34.661025Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"del(test_df)\ngc.collect()","metadata":{"execution":{"iopub.status.busy":"2022-05-31T08:39:42.891251Z","iopub.execute_input":"2022-05-31T08:39:42.89182Z","iopub.status.idle":"2022-05-31T08:39:43.009733Z","shell.execute_reply.started":"2022-05-31T08:39:42.891737Z","shell.execute_reply":"2022-05-31T08:39:43.008779Z"},"trusted":true},"execution_count":null,"outputs":[]}]}