{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":67356,"databundleVersionId":8006601,"sourceType":"competition"}],"dockerImageVersionId":30698,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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\n# import numpy as np # linear algebra\n# import 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\n# import os\n# for 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","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import polars as pl","metadata":{"execution":{"iopub.status.busy":"2024-05-05T20:39:13.038464Z","iopub.execute_input":"2024-05-05T20:39:13.038925Z","iopub.status.idle":"2024-05-05T20:39:13.391329Z","shell.execute_reply.started":"2024-05-05T20:39:13.038888Z","shell.execute_reply":"2024-05-05T20:39:13.389875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# %%time\n\n# df = (\n#     pl.read_csv('/kaggle/input/leash-BELKA/train.csv', has_header=False,\n#                 columns=[0, 4, 5, 6], new_columns=['id', 'molecule_smiles', 'protein_name', 'binds'],\n# #                 columns=[\n# # #         'buildingblock1_smiles',\n# # #         'buildingblock2_smiles',\n# # #         'buildingblock3_smiles',\n# #         'molecule_smiles',\n# #         'protein_name',\n# #         'binds'\n# #     ],\n#                 skip_rows=3, n_rows=1000)\n# #     .with_columns(pl.col('buildingblock1_smiles').cast(pl.Categorical))\n# #     .with_columns(pl.col('buildingblock2_smiles').cast(pl.Categorical))\n# #     .with_columns(pl.col('buildingblock3_smiles').cast(pl.Categorical))\n# )","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# df.shape","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# pl.scan_csv()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pl.__version__","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n\npl.scan_parquet('/kaggle/input/leash-BELKA/train.parquet').select(pl.len()).collect().item()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# %%time\n\n# pl.scan_csv('/kaggle/input/leash-BELKA/train.csv').select(pl.len()).collect().item()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n\ndf = (\n    pl.read_parquet('/kaggle/input/leash-BELKA/train.parquet')\n    [157:169]\n    .collect()\n)","metadata":{"execution":{"iopub.status.busy":"2024-05-05T20:42:15.86215Z","iopub.execute_input":"2024-05-05T20:42:15.866428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n\ndf = (\n    pl.scan_csv('/kaggle/input/leash-BELKA/train.csv')\n    [1570000:1570200]\n    .collect()\n)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pl.show_versions()","metadata":{"execution":{"iopub.status.busy":"2024-05-05T20:39:16.78774Z","iopub.execute_input":"2024-05-05T20:39:16.789143Z","iopub.status.idle":"2024-05-05T20:39:19.772371Z","shell.execute_reply.started":"2024-05-05T20:39:16.78909Z","shell.execute_reply":"2024-05-05T20:39:19.770772Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# import duckdb","metadata":{"execution":{"iopub.status.busy":"2024-05-05T21:02:42.141346Z","iopub.execute_input":"2024-05-05T21:02:42.141821Z","iopub.status.idle":"2024-05-05T21:02:42.14658Z","shell.execute_reply.started":"2024-05-05T21:02:42.141772Z","shell.execute_reply":"2024-05-05T21:02:42.145547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install 'ibis-framework[duckdb]'","metadata":{"execution":{"iopub.status.busy":"2024-05-06T10:18:26.886644Z","iopub.execute_input":"2024-05-06T10:18:26.887108Z","iopub.status.idle":"2024-05-06T10:18:49.35653Z","shell.execute_reply.started":"2024-05-06T10:18:26.887077Z","shell.execute_reply":"2024-05-06T10:18:49.355145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import ibis","metadata":{"execution":{"iopub.status.busy":"2024-05-06T10:18:49.359448Z","iopub.execute_input":"2024-05-06T10:18:49.360317Z","iopub.status.idle":"2024-05-06T10:18:49.864489Z","shell.execute_reply.started":"2024-05-06T10:18:49.360265Z","shell.execute_reply":"2024-05-06T10:18:49.86322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = ibis.read_parquet('/kaggle/input/leash-BELKA/train.parquet')","metadata":{"execution":{"iopub.status.busy":"2024-05-06T10:18:49.866144Z","iopub.execute_input":"2024-05-06T10:18:49.866619Z","iopub.status.idle":"2024-05-06T10:18:50.737911Z","shell.execute_reply.started":"2024-05-06T10:18:49.866577Z","shell.execute_reply":"2024-05-06T10:18:50.736888Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.count()","metadata":{"execution":{"iopub.status.busy":"2024-05-06T10:18:50.739979Z","iopub.execute_input":"2024-05-06T10:18:50.741405Z","iopub.status.idle":"2024-05-06T10:18:50.753291Z","shell.execute_reply.started":"2024-05-06T10:18:50.741366Z","shell.execute_reply":"2024-05-06T10:18:50.750928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[100000:100020].to_pandas()","metadata":{"execution":{"iopub.status.busy":"2024-05-06T10:18:57.457321Z","iopub.execute_input":"2024-05-06T10:18:57.458417Z","iopub.status.idle":"2024-05-06T10:18:57.886591Z","shell.execute_reply.started":"2024-05-06T10:18:57.458378Z","shell.execute_reply":"2024-05-06T10:18:57.885052Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df[100000:100001].to_pandas()","metadata":{"execution":{"iopub.status.busy":"2024-05-06T10:19:52.751336Z","iopub.execute_input":"2024-05-06T10:19:52.751707Z","iopub.status.idle":"2024-05-06T10:19:52.820292Z","shell.execute_reply.started":"2024-05-06T10:19:52.751678Z","shell.execute_reply":"2024-05-06T10:19:52.819055Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}