{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "f74e9cb5-1536-7f0a-c5a1-6d009a397fc1"
      },
      "source": [
        "## Random Data Exploration or Whatever ##"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "f764c7ad-758d-58e5-4006-4159d6a38234"
      },
      "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",
        "import matplotlib.pyplot as plt\n",
        "plt.style.use('ggplot')\n",
        "import numpy as np # linear algebra\n",
        "import 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",
        "\n",
        "from subprocess import check_output\n",
        "print(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))\n",
        "\n",
        "# Any results you write to the current directory are saved as output."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "ee37163d-6fe6-ff49-e2c6-a3ab1f506b36"
      },
      "outputs": [],
      "source": [
        "df = pd.read_csv(\"../input/train.csv\")\n",
        "print(\"done\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "6702e3a6-21e3-e843-2478-2ee97e781ad0"
      },
      "source": [
        "The check-in locations seem somewhat evenly distributed."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "e21365bd-5a90-74b0-14dd-98179235eae2"
      },
      "outputs": [],
      "source": [
        "df.sample(frac=.001).plot(kind='hexbin', x='x', y='y', gridsize=25)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "3300d9f9-3d1a-c6bb-4b9b-6974c7540ac4"
      },
      "source": [
        "There are clear peaks and troughs in check-in times"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "1429a618-4b01-630a-5c55-7cd9e27792a8"
      },
      "outputs": [],
      "source": [
        "df.sample(frac=.001)[\"time\"].plot(kind=\"density\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "d9e538db-f129-c488-b5ad-3d442846de11"
      },
      "source": [
        "For each `place_id`, how spread out are check-in locations? We plotted the ranges for `x` and `y` for each `place_id`."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "0c4ac680-35bc-3389-2804-ae805fc3d3d2"
      },
      "outputs": [],
      "source": [
        "places = df.groupby('place_id')\n",
        "dists = places.max() - places.min()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "43bec4dd-9063-4979-2d9a-0d859da61cf3"
      },
      "outputs": [],
      "source": [
        "stds = places.std()\n",
        "# IDK why it won't let me plot this..."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "47c0ed2f-8fee-bba2-ef0d-401dddb14426"
      },
      "outputs": [],
      "source": [
        "plt.violinplot([dists[\"x\"], dists[\"y\"]])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "3e0446cb-f4d5-3d4f-da5d-5af295638bd2"
      },
      "outputs": [],
      "source": [
        "places.min().mean()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "0e576fd4-2773-268a-a553-afaf80e386ad"
      },
      "source": [
        "## Data Cleaning ##\n",
        "\n",
        "The data is pretty damn clean. No missing values, and all the variables are in reasonable ranges."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "fe686c7d-c812-7595-344f-ff3d6eb6d020"
      },
      "outputs": [],
      "source": [
        "# missing values\n",
        "df.isnull().sum()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "eaa0e2de-eb59-ea68-9369-4081ba4607b9"
      },
      "outputs": [],
      "source": [
        "# max values\n",
        "df.max()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "f452c2fd-6f0b-0319-6518-8d4ac3a96495"
      },
      "outputs": [],
      "source": [
        "# min values\n",
        "df.min()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "be091112-98a6-89ae-6ba5-c8a137945373"
      },
      "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
}