{"cells":[{"metadata":{},"cell_type":"markdown","source":"**Goal: for each building and meter pair, visualize where target is missing and where target is zero VS time**"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\n# Load data\ntrain = pd.read_csv('/kaggle/input/ashrae-energy-prediction/train.csv')\ntrain['timestamp'] = pd.to_datetime(train.timestamp)\ntrain = train.set_index(['timestamp'])\n\n# Plot missing values per building/meter\nf,a=plt.subplots(1,4,figsize=(20,30))\nfor meter in np.arange(4):\n    df = train[train.meter==meter].copy().reset_index()\n    df['timestamp'] = pd.to_timedelta(df.timestamp).dt.total_seconds() / 3600\n    df['timestamp'] = df.timestamp.astype(int)\n    df.timestamp -= df.timestamp.min()\n    missmap = np.empty((1449, df.timestamp.max()+1))\n    missmap.fill(np.nan)\n    for l in df.values:\n        if l[2]!=meter:continue\n        missmap[int(l[1]), int(l[0])] = 0 if l[3]==0 else 1\n    a[meter].set_title(f'meter {meter:d}')\n    sns.heatmap(missmap, cmap='Paired', ax=a[meter], cbar=False)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"markdown","source":"**Legend:**\n- **X axis:** hours elapsed since Jan 1st 2016, for each of the 4 meter types\n- **Y axis:** building_id\n- **Brown:** meter reading available with non-zero value\n- **Light blue:** meter reading available with zero value\n- **White:** missing meter reading"}],"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":4,"nbformat_minor":1}