{"cells":[
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "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 sqlite3 as sql\nimport 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\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n\n# Any results you write to the current directory are saved as output.\nimport matplotlib.pyplot as plt\n\ndf_train = pd.read_csv('../input/train.csv')\ndf_test = pd.read_csv('../input/test.csv')\ndf_sample = pd.read_csv('../input/sample_submission.csv')"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "df_train['time'].describe()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "df_train.head()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "df_test.head()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "df_sample.head()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "time = df_train['time']\ntime = time % (24*60)#*60#*60*10\n\nn, bins, patches = plt.hist(time, 50)\nplt.title('What is Time?')\nplt.xlabel('Time')\nplt.ylabel('Frequency')\nplt.grid(True)\nplt.show()\n#So, 1 of 3 things is happening: Nothing happens cyclically with time; time isn't based on hours, minutes, seconds, or sub-seconds; or they've given us data that aggregates to the same use for each hour.\n#Option 3 sounds most promising, so let's dive into that"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "df_train['place_id'].value_counts().head(10) #get the top places to breakout time\noffset=0 # This can be adjusted if we figure out what time midnight is\n#Let's take a look at how each individual place breaks down with time"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "time = df_train[df_train['place_id']==8772469670]['time']\n\ntimeToTest=24*60#*60#*60*10\n\ntime = (time+offset) % timeToTest\n\nn, bins, patches = plt.hist(time, 50)\nplt.title('What is Time?')\nplt.xlabel('Time')\nplt.ylabel('Frequency')\nplt.grid(True)\nplt.show()\ntime = df_train[df_train['place_id']==1623394281]['time']"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "time = (time+offset) % timeToTest\n\nn, bins, patches = plt.hist(time, 50)\nplt.title('What is Time?')\nplt.xlabel('Time')\nplt.ylabel('Frequency')\nplt.grid(True)\nplt.show()\ntime = df_train[df_train['place_id']==1308450003]['time']"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "time = (time+offset) % timeToTest\n\nn, bins, patches = plt.hist(time, 50)\nplt.title('What is Time?')\nplt.xlabel('Time')\nplt.ylabel('Frequency')\nplt.grid(True)\nplt.show()\ntime = df_train[df_train['place_id']==4823777529]['time']"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "time = (time+offset) % timeToTest\n\nn, bins, patches = plt.hist(time, 50)\nplt.title('What is Time?')\nplt.xlabel('Time')\nplt.ylabel('Frequency')\nplt.grid(True)\nplt.show()"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": "#Strong case for this dataset being in minutes.\n#Let's see how much time this data has been collected for\nprint('Time since start of data collection: ' + str(round(df_train['time'].max()/(24*60*365.25),2)) + ' Years.')"
 },
 {
  "cell_type": "code",
  "execution_count": null,
  "metadata": {
   "collapsed": false
  },
  "outputs": [],
  "source": ""
 }
],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"}}, "nbformat": 4, "nbformat_minor": 0}