{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":9994,"databundleVersionId":752467,"sourceType":"competition"}],"dockerImageVersionId":30587,"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\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":"2023-11-22T14:00:02.647266Z","iopub.execute_input":"2023-11-22T14:00:02.647685Z","iopub.status.idle":"2023-11-22T14:00:03.127871Z","shell.execute_reply.started":"2023-11-22T14:00:02.64765Z","shell.execute_reply":"2023-11-22T14:00:03.126691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Read data yang ingin digunakan\ndata=pd.read_csv(r'/kaggle/input/ashrae-energy-prediction/train.csv')\ndata","metadata":{"execution":{"iopub.status.busy":"2023-11-22T14:00:03.129857Z","iopub.execute_input":"2023-11-22T14:00:03.130385Z","iopub.status.idle":"2023-11-22T14:00:21.371186Z","shell.execute_reply.started":"2023-11-22T14:00:03.130343Z","shell.execute_reply":"2023-11-22T14:00:21.36999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Cek data type\ndata.info()","metadata":{"execution":{"iopub.status.busy":"2023-11-22T14:08:17.598051Z","iopub.execute_input":"2023-11-22T14:08:17.598453Z","iopub.status.idle":"2023-11-22T14:08:17.647542Z","shell.execute_reply.started":"2023-11-22T14:08:17.598422Z","shell.execute_reply":"2023-11-22T14:08:17.643482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Ubah data type timestamp dari object menjadi index untuk membagi data perbulan\ntimedata=pd.read_csv(r'/kaggle/input/ashrae-energy-prediction/train.csv',parse_dates=True, index_col = \"timestamp\")\ntimedata","metadata":{"execution":{"iopub.status.busy":"2023-11-22T14:09:25.834858Z","iopub.execute_input":"2023-11-22T14:09:25.835341Z","iopub.status.idle":"2023-11-22T14:09:41.730609Z","shell.execute_reply.started":"2023-11-22T14:09:25.835306Z","shell.execute_reply":"2023-11-22T14:09:41.729484Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Cek missing value\ntimedata.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-11-22T14:10:29.148481Z","iopub.execute_input":"2023-11-22T14:10:29.14891Z","iopub.status.idle":"2023-11-22T14:10:29.22972Z","shell.execute_reply.started":"2023-11-22T14:10:29.148867Z","shell.execute_reply":"2023-11-22T14:10:29.228385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Buat data untuk rata-rata perbulan\ndf_month = timedata.resample(\"M\").mean()\ndf_month","metadata":{"execution":{"iopub.status.busy":"2023-11-22T14:10:45.496046Z","iopub.execute_input":"2023-11-22T14:10:45.496427Z","iopub.status.idle":"2023-11-22T14:10:46.801285Z","shell.execute_reply.started":"2023-11-22T14:10:45.496399Z","shell.execute_reply":"2023-11-22T14:10:46.7999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Plot penggunaan listrik perbulan\nimport matplotlib.pyplot as plt\nreading_plot = df_month['meter_reading'].plot(figsize=(8, 5),marker='o')\nreading_plot.set_xlabel('Month')\nreading_plot.set_ylabel('kWh consumption')\nplt.title('kWh Consumption per-month in 2016')","metadata":{"execution":{"iopub.status.busy":"2023-11-22T14:12:46.276377Z","iopub.execute_input":"2023-11-22T14:12:46.276801Z","iopub.status.idle":"2023-11-22T14:12:46.614165Z","shell.execute_reply.started":"2023-11-22T14:12:46.276768Z","shell.execute_reply":"2023-11-22T14:12:46.612965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}}]}