{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "51b731de-6f41-f15c-d636-53fdff97720f"
      },
      "source": [
        "Data exploration\n",
        "----------------"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "2ce01a8f-abc6-3eb3-3305-1bd66e8cc9ed"
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "74caf205-3d5b-80a7-5f62-fb7daa46e103"
      },
      "outputs": [],
      "source": [
        "data = pd.read_csv('../input/train.csv')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0b215893-9fb3-1136-aaa2-d28402ab00ed"
      },
      "outputs": [],
      "source": [
        "data.head()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "6c5348ea-1689-900e-383f-061425737e76"
      },
      "outputs": [],
      "source": [
        "N = 100\n",
        "frames = []\n",
        "for i in range(N):\n",
        "    place_id = data.loc[i]['place_id']\n",
        "    frames.append(data[data.place_id == place_id])\n",
        "\n",
        "dataN = pd.concat(frames)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "3018695b-3faf-330f-0936-78ddfeb17dff"
      },
      "outputs": [],
      "source": [
        "plt.figure(figsize=(10,10))\n",
        "plt.scatter(dataN['x'], dataN['y'], s=1, c=dataN['place_id'], linewidths=0)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "6fd7b87f-8d09-269b-4c78-3eaa735e08ee"
      },
      "outputs": [],
      "source": [
        "MINUTES_IN_DAY = 60 * 24\n",
        "MINUTES_IN_MONTH = 30 * MINUTES_IN_DAY\n",
        "START = min(dataN['time'])\n",
        "\n",
        "day_of_week = ((dataN['time'] - START) // MINUTES_IN_DAY) % 7\n",
        "time_of_day = (dataN['time'] - START) % MINUTES_IN_DAY\n",
        "month_of_year = ((dataN['time'] - START) // MINUTES_IN_MONTH) % 12\n",
        "\n",
        "dataN['day_of_week'] = day_of_week\n",
        "dataN['time_of_day'] = time_of_day\n",
        "dataN['month_of_year'] = month_of_year"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "885e6926-2ae6-b729-0b39-723674db1849"
      },
      "outputs": [],
      "source": [
        "dataN.head()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "986be8c1-b3fd-b6ba-1bea-00774e9e0456"
      },
      "outputs": [],
      "source": [
        "plt.hist(dataN[dataN['place_id']==8523065625]['day_of_week'])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "d98e1faf-5867-1475-6450-9834cbf5d689"
      },
      "outputs": [],
      "source": [
        "dataN[dataN['place_id']==8523065625]['day_of_week']"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "5c9a4ff4-bfa9-b88c-900d-b4b145bf43bb"
      },
      "outputs": [],
      "source": ""
    }
  ],
  "metadata": {
    "_change_revision": 0,
    "_is_fork": false,
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.5.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}