{"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)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\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":"train = pd.read_csv(\"../input/train.csv\")\ntrain.dtypes","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"140bffe173a9161d87e6c1d9e054fddb8eed4125"},"cell_type":"code","source":"test = pd.read_csv(\"../input/test.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9f8670d1c35f1160e1dcdedb88124aebd2a3692e"},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7d4af8222f72cc43fb89e9c49b417524ee778c97"},"cell_type":"code","source":"test.head(10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d0aaa923c921d980c730c43bce031d464f9aae64"},"cell_type":"code","source":"#Function to return column name based on Index","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"76b34e28f8a08f54e22e7cfa280224d0c6e3eb0a"},"cell_type":"code","source":"train.columns.get_values()[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6f2ba5c87b4e7ba248a70ea22026aba3f333b1ff"},"cell_type":"code","source":"#To return column index based on column name","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1de8b5bd4cb3c524cf7c2f96caf5d37d34031b15"},"cell_type":"code","source":"def column_index(train, query_cols):\n    cols = train.columns.values\n    sidx = np.argsort(cols)\n    return sidx[np.searchsorted(cols,query_cols,sorter=sidx)]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"99b5cc1258448685108e683d014096c3ab478577"},"cell_type":"code","source":"column_index(train,\"card_id\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d411c447322092ae5fbe94e4e6be9b542a356a2f"},"cell_type":"code","source":"#Shortcut way to know the column names whenever required","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7644855e9d23784fe9cec70e7b4b8fa0cfbe8ccd"},"cell_type":"code","source":"list(train.columns.values)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c2a80906e07f4ca61b581d4217618c68d4760d8c"},"cell_type":"code","source":"s1 = train.feature_1.value_counts()\n\ns1\n\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4274782f036b0e56e5506bbc45f560823369c5b6"},"cell_type":"code","source":"sns.distplot(s1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9fa3e21ac9130ac0bc525e1596a9649a48dd2207"},"cell_type":"code","source":"s2 = train.first_active_month.value_counts()\ns2.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f14d12c90e3ac16f6c72be47a7ed7b7405680104"},"cell_type":"code","source":"def strToDate(string):\n    d = datetime.strptime(string, '%Y-%m-%d')\n    return d;\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bd8333b8940d72dd36a2a969b76be265b74617b1"},"cell_type":"code","source":" #feature_1 vs target\n# Initialize a grid of plots with an Axes for each walk\ngrid = sns.FacetGrid(train, col=\"feature_1\", hue=\"feature_1\", palette=\"tab20c\",\n                     col_wrap=4, height=1.5)\n\n# Draw a horizontal line to show the starting point\ngrid.map(plt.axhline, y=0, ls=\":\", c=\".5\")\n\n# Draw a line plot to show the trajectory of each random walk\ngrid.map(plt.plot, \"target\", \"first_active_month\", marker=\"o\")\n\n# Adjust the tick positions and labels\ngrid.set(xticks=np.arange(3), yticks=[-3, 3],\n         xlim=(-.5, 4.5), ylim=(0, 5))\n\n# Adjust the arrangement of the plots\ngrid.fig.tight_layout(w_pad=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2645725bb2ae2977bc430727a5e7a39110f9c863"},"cell_type":"code","source":"#cmap = sns.cubehelix_palette(rot=-.2, as_cmap=True)\nax = sns.scatterplot(x=\"target\", y=\"feature_1\",\n                     hue=\"first_active_month\", size=\"feature_1\",\n                     sizes=(100, 200),\n                     data=train)","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}