{"cells":[{"metadata":{},"cell_type":"markdown","source":"# CEE 498DS Project 11: EDA\nThe main purpose of this notebook is the exploratory data analysis (EDA) in ASHRAE - Great Energy Predictor III. There are 6 files in this project in total. The notebook will need to consider the historic usage rates and the different weather in the specific location and time. \n"},{"metadata":{},"cell_type":"markdown","source":"# 1.Data Imports"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"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\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport os","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"# 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\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 5GB 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","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Read the CVS file and transform them as Pandas Dataframe\nweather_test_df = pd.read_csv('/kaggle/input/ashrae-energy-prediction/weather_test.csv')\nbuilding_meta_df = pd.read_csv('/kaggle/input/ashrae-energy-prediction/building_metadata.csv')\ntrain_df = pd.read_csv('/kaggle/input/ashrae-energy-prediction/train.csv')\nweather_train_df = pd.read_csv('/kaggle/input/ashrae-energy-prediction/weather_train.csv')\ntest_df = pd.read_csv('/kaggle/input/ashrae-energy-prediction/test.csv')\nsample_submission = pd.read_csv('/kaggle/input/ashrae-energy-prediction/sample_submission.csv')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# 2. Information about the data"},{"metadata":{"trusted":true},"cell_type":"code","source":"#Check if they are imported correctly\n#Count the number of rows in each table\nweather_test_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"weather_test_df.shape[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"building_meta_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"building_meta_df.shape[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.shape[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"weather_train_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"weather_train_df.shape[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.shape[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"sample_submission.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# 3. Analysis of the data"},{"metadata":{"trusted":true},"cell_type":"code","source":"#the number of buidling in this project\nlen(building_meta_df.building_id.unique())","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"#primary_use of the buidling in this project\nlen(building_meta_df.primary_use.unique())","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure()\nsns.barplot(building_meta_df.primary_use.value_counts().index,building_meta_df.primary_use.value_counts())\nplt.xticks(rotation = 90)\nplt.ylabel('Quanity of Buildings',fontsize=16)\nplt.xlabel('primary_use',fontsize=16)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure()\nsns.barplot(building_meta_df.site_id.value_counts().index,building_meta_df.site_id.value_counts())\nplt.ylabel('Quanity of Buildings',fontsize=16)\nplt.xlabel('Site_id',fontsize=16)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.figure(figsize=(20,3))\nsns.barplot(building_meta_df.year_built.value_counts().index,building_meta_df.year_built.value_counts())\nplt.ylabel('Quanity of Buildings',fontsize=16)\nplt.xlabel('year_built',fontsize=16)\nplt.xticks(rotation = 90)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"fig,ax=plt.subplots(figsize=(15, 10))\nsns.distplot(building_meta_df['square_feet'], color='orange', ax=ax)\nplt.xlabel('square_feet',fontsize=16)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# 4.Merge the data and analyze it deeper"},{"metadata":{"trusted":true},"cell_type":"code","source":"test = pd.merge(test_df,building_meta_df,on = ['building_id'],how = 'left')           \ntest.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test = pd.merge(test,weather_test_df, on = ['site_id','timestamp'], how = 'left')\ntest.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test.hist(figsize=(20,20))","execution_count":null,"outputs":[]}],"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":4}