{"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":56537,"databundleVersionId":8015876,"sourceType":"competition"}],"dockerImageVersionId":30698,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd","metadata":{"execution":{"iopub.status.busy":"2024-04-19T09:54:59.700894Z","iopub.execute_input":"2024-04-19T09:54:59.70145Z","iopub.status.idle":"2024-04-19T09:55:00.708008Z","shell.execute_reply.started":"2024-04-19T09:54:59.70142Z","shell.execute_reply":"2024-04-19T09:55:00.706533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission = pd.read_csv(\"/kaggle/input/leap-atmospheric-physics-ai-climsim/sample_submission.csv\")\ntargets = [x for x in sample_submission.columns if x not in [\"sample_id\"]]","metadata":{"execution":{"iopub.status.busy":"2024-04-19T09:55:00.710265Z","iopub.execute_input":"2024-04-19T09:55:00.711429Z","iopub.status.idle":"2024-04-19T09:55:57.810958Z","shell.execute_reply.started":"2024-04-19T09:55:00.711384Z","shell.execute_reply":"2024-04-19T09:55:57.809812Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"means = []\n\nchunksize = 10_000\nfor idx, chunk in enumerate(pd.read_csv(\"/kaggle/input/leap-atmospheric-physics-ai-climsim/train.csv\", chunksize=chunksize, usecols=targets)):\n    means.append(chunk.mean())\n    print(idx, end=\" \")\n    if idx > 100:\n        break","metadata":{"execution":{"iopub.status.busy":"2024-04-19T10:25:22.374349Z","iopub.execute_input":"2024-04-19T10:25:22.374991Z","iopub.status.idle":"2024-04-19T10:25:30.53152Z","shell.execute_reply.started":"2024-04-19T10:25:22.374967Z","shell.execute_reply":"2024-04-19T10:25:30.529615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_means = pd.concat(means, axis=1).T.mean()\nfinal_means","metadata":{"execution":{"iopub.status.busy":"2024-04-19T10:25:33.278701Z","iopub.execute_input":"2024-04-19T10:25:33.279062Z","iopub.status.idle":"2024-04-19T10:25:33.301225Z","shell.execute_reply.started":"2024-04-19T10:25:33.279033Z","shell.execute_reply":"2024-04-19T10:25:33.300483Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in final_means.keys():\n    sample_submission[col] = sample_submission[col] * final_means[col]","metadata":{"execution":{"iopub.status.busy":"2024-04-19T10:25:36.074806Z","iopub.execute_input":"2024-04-19T10:25:36.075138Z","iopub.status.idle":"2024-04-19T10:25:37.211702Z","shell.execute_reply.started":"2024-04-19T10:25:36.075116Z","shell.execute_reply":"2024-04-19T10:25:37.210536Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sample_submission.to_csv(\"submission.csv\", index=False)","metadata":{"execution":{"iopub.status.busy":"2024-04-19T10:25:39.342892Z","iopub.execute_input":"2024-04-19T10:25:39.343232Z","iopub.status.idle":"2024-04-19T10:30:30.535972Z","shell.execute_reply.started":"2024-04-19T10:25:39.343208Z","shell.execute_reply":"2024-04-19T10:30:30.534348Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!wc -l /kaggle/working/submission.csv # should be 625001","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}