{"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 the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"df_train = pd.read_csv('../input/train.csv')\ndf_train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b058c5caefa9f435325c9415c0d9a338f7041d92"},"cell_type":"code","source":"df_merchants = pd.read_csv('../input/merchants.csv')\ndf_merchants.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b5576855f7c5838b7b75795f996ed064c686f485"},"cell_type":"code","source":"df_new_merchant_transactions = pd.read_csv('../input/new_merchant_transactions.csv')\ndf_new_merchant_transactions.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"012d190193c8349c6ff13bb91c2a1831135f3775"},"cell_type":"code","source":"df_historical_transactions = pd.read_csv('../input/historical_transactions.csv')\ndf_historical_transactions.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a5a94f194b4c3295cc307f3fd7e6ef1541423518"},"cell_type":"code","source":"dict_dfs = {'df_train': df_train, \n          'df_merchants': df_merchants, \n          'df_historical_transactions': df_historical_transactions, \n          'df_new_merchant_transactions': df_new_merchant_transactions}","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b051815fe90323e12453bfc467de29ee771eb0c2"},"cell_type":"code","source":"df_train.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c0a958437d24939de2956ded244602445f0f73b7"},"cell_type":"code","source":"df_train['target'].hist(bins=100)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"89c6634493762a2369f65311652508fda6973753"},"cell_type":"code","source":"# 2207 values are located on the left tail of the target distribution\nsum((df_train['target'] > -33.3) & (df_train['target'] < -33))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"77188488e15731570f329ef54a9748446e4f3910"},"cell_type":"code","source":"# This left tail appears to be the minimum target value\nmax_target = np.max(df_train['target'])\nmin_target = np.min(df_train['target'])\nleft_tail_mask = (df_train['target'] == min_target)\nprint(sum(left_tail_mask))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0597d1ce1f19e24f5ff6eba855c7713efa252ce4"},"cell_type":"code","source":"min_to_9_mask = (df_train['target'] > min_target) & (df_train['target'] < -9)\nsum(min_to_10_mask)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"91afde4b5e1789beaaf22b7ace2dfd5089e4a3c8"},"cell_type":"code","source":"# Seems like the target distribution is normal except the left tail (minimum value)\ndf_train['target'][min_to_10_mask].hist(bins=10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"46f7a4b1161e91713eaa24ed2c5200d0c83f5988"},"cell_type":"code","source":"nine_to_max_mask = (df_train['target'] > 9) & (df_train['target'] <= max_target)\nsum(nine_to_max_mask)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7133baa8eb8fbc8fa38ae19775f8b582a9df5898"},"cell_type":"code","source":"df_train['target'][nine_to_max_mask].hist(bins=10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"cc7baff3a4c9d5a10a1bee9c2a558af62da96926"},"cell_type":"code","source":"# Checking for missing values\ndef check_null(df):\n    for col in df.columns:\n        print('{}: {}'.format(col, sum(df[col].isnull())))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5192437da12df254f35c8d58a4e1c47c6b7962e6"},"cell_type":"code","source":"for df_name in dict_dfs:\n    print('--------------Number of NaNs in {}----------------'.format(df_name))\n    check_null(dict_dfs[df_name])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9e15c3f958e02eff43f6e572758ca3c6163f9ebb"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}