{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "_cell_guid": "a5dd5825-54e2-0f35-3097-68e02467fca5"
      },
      "source": [
        "## I was planning on joining the document data to promoted content, but there isn't enough kernel memory ##"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "628f8e8f-357f-a26b-6042-6587e599c084"
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plot\n",
        "import seaborn as sns\n",
        "\n",
        "\n",
        "from subprocess import check_output\n",
        "print(check_output([\"ls\", \"../input\"]).decode(\"utf8\"))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "b379bd2c-341a-d380-fee8-c80e13a45519"
      },
      "outputs": [],
      "source": [
        "# Can't seem to load the events it exceeds max kernel memory :(\n",
        "#events = pd.read_csv('../input/events.csv', dtype={'uuid': np.str, 'display_id': np.str, 'document_id': np.str, 'geo_location': np.str})"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "f17b2c99-523c-48de-1cc3-517758b9a96b"
      },
      "outputs": [],
      "source": [
        "documents_cat = pd.read_csv('../input/documents_categories.csv').rename(columns={'confidence_level': 'category_confidence_level'})\n",
        "documents_cat"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "33faee19-6925-8d6d-2822-df6dfe6f9883"
      },
      "outputs": [],
      "source": [
        "documents_ent = pd.read_csv('../input/documents_entities.csv').rename(columns={'confidence_level': 'entity_confidence_level'})\n",
        "documents_ent"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "b1a78864-44cc-4310-a320-a340e960380b"
      },
      "outputs": [],
      "source": [
        "documents_meta = pd.read_csv('../input/documents_meta.csv', parse_dates=['publish_time'], dtype={'source_id': np.str, 'publisher_id': np.str, 'document_id': np.str})\n",
        "documents_meta"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "ebeac2ec-84f9-10c5-da7b-b1ecb8c80bf0"
      },
      "outputs": [],
      "source": [
        "document_topics = pd.read_csv('../input/documents_topics.csv', dtype={'document_id': np.str, 'topic_id': np.str}).rename(columns={'confidence_level': 'topic_confidence_level'})\n",
        "document_topics"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "a9c036f1-ce99-4433-a91e-ef6f8b612967"
      },
      "outputs": [],
      "source": [
        "promoted_content = pd.read_csv('../input/promoted_content.csv', dtype={'ad_id': np.str, 'document_id': np.str, 'campaign_id': np.str, 'advertiser_id': np.str})\n",
        "promoted_content"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "b0749d85-b875-4a77-7536-2e70e300fbaf"
      },
      "outputs": [],
      "source": [
        "promoted_joined = pd.merge(promoted_content, document_topics, how='outer', on=['document_id'])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "b0447fd4-3be5-af9a-e69b-f569d56a0ec9"
      },
      "outputs": [],
      "source": [
        "promoted_joined"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "6353722b-ec7d-6903-ba4d-c5e2a384d5d8"
      },
      "outputs": [],
      "source": [
        "promoted_joined = pd.merge(promoted_joined, documents_meta, how='outer', on=['document_id'])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "79cba023-af9b-ac51-a483-f60e6b34c72b"
      },
      "outputs": [],
      "source": [
        "promoted_joined"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "_cell_guid": "155f79d1-917d-a5f7-0e54-60539a0b7c57"
      },
      "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
}