{"cells":[{"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 in \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 \"../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# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"","_uuid":"","trusted":true},"cell_type":"code","source":"import pandas as pd\nbuilding_metadata = pd.read_csv(\"../input/ashrae-energy-prediction/building_metadata.csv\")\nsample_submission = pd.read_csv(\"../input/ashrae-energy-prediction/sample_submission.csv\")\ntest = pd.read_csv(\"../input/ashrae-energy-prediction/test.csv\")\ntrain = pd.read_csv(\"../input/ashrae-energy-prediction/train.csv\")\nweather_test = pd.read_csv(\"../input/ashrae-energy-prediction/weather_test.csv\")\nweather_train = pd.read_csv(\"../input/ashrae-energy-prediction/weather_train.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Merging data sets. The pd.merge() function recognizes that each DataFrame has an \"employee\" column, and automatically joins using this column as a key. \n# Merging training data & building meta data\n\ndf = pd.merge(train, building_metadata)\n\n# listing the columns\nlist(df.columns) ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Merging df with weather data\ndff = pd.merge(df, weather_train)\n\n# listing the columns\nlist(dff.columns)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# checking data types \n\nprint(dff.dtypes)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Looking at distributions of the columns using data.hist feature & defining the size of the plot using matplotlib\n\nimport matplotlib.pyplot as plt\n\nfig = plt.figure(figsize = (10,10))\nax = fig.gca()\ndff.hist(ax=ax)\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Meter reading has a peak - replotting histogram\n\ndff.hist(column='meter_reading', bins = 5)\n\n# Looks like there are outliers","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"dff.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Removing outliers in meter reading\n# For your dataframe column, you could get quantile with:\nq = dff[\"meter_reading\"].quantile(0.95)\n\n#and then filter with:\n\ndfout = dff[dff[\"meter_reading\"] < q]\ndfout.hist(column='meter_reading')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Precep depth also seems to have outliers looking at the histogram - cleaning that with same steps as above\n\n# Removing outliers in precipitation depth\n# For your dataframe column, you could get quantile with:\nr = dfout[\"precip_depth_1_hr\"].quantile(0.99)\n\n#and then filter with:\n\ndfouts = dfout[dfout[\"precip_depth_1_hr\"] < r]\ndfouts.hist(column='precip_depth_1_hr')\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Merging test data sets as well using the same steps\n\n# Merging data sets. The pd.merge() function recognizes that each DataFrame has an \"employee\" column, and automatically joins using this column as a key. \n# Merging training data & building meta data\n\n#dft = pd.merge(test, building_metadata)\n\n# Merging df with weather data\n#dfft = pd.merge(dft, weather_test)\n\n# listing the columns\n#list(dfft.columns)","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":1}