{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Basics"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:01:59.316035Z",
     "start_time": "2019-03-22T21:01:45.087Z"
    }
   },
   "outputs": [],
   "source": [
    "from arche import *"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Any project requires auth which is done with an api key set in `SH_APIKEY`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:01:39.943889Z",
     "start_time": "2019-03-22T21:01:39.940823Z"
    }
   },
   "outputs": [],
   "source": [
    "a = Arche(\"235801/1/15\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:01:50.955877Z",
     "start_time": "2019-03-22T21:01:39.951101Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e25e963ad4a9431cbafe8d0d5d0984eb",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Downloading 0:1000', max=1000, style=ProgressStyle(descriptio…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "7e90b08f008c41dfb8c23e38a0c3a163",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Flattening df', max=6, style=ProgressStyle(description_width=…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "Job Outcome:\n",
      "\tFinished\n",
      "\n",
      "Job Errors:\n",
      "\tNo errors\n",
      "\n",
      "Responses Per Item Ratio:\n",
      "\tNumber of responses / Number of scraped items - 1.05\n",
      "\n",
      "Fields Coverage:\n",
      "\t0 totally empty field(s)\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "RULE: Fields Coverage\n",
      "(1 message(s))\n",
      "\n",
      "             Values Count  Percent\n",
      "Field                             \n",
      "description           998       99\n",
      "_key                 1000      100\n",
      "_type                1000      100\n",
      "category             1000      100\n",
      "price                1000      100\n",
      "title                1000      100\n"
     ]
    }
   ],
   "source": [
    "a.report_all()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We just ran a minimal number of rules. The validation can be improved with adding a json schema, let's infer one from the data we already have."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## JSON schema"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:01:59.279211Z",
     "start_time": "2019-03-22T21:01:50.965889Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "f8deafecac8a4b6b8eef19ceab8902e9",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Downloading 162:163', max=1, style=ProgressStyle(description_…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c2a0851fcbed48eaa0944df1381091d3",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Downloading 194:195', max=1, style=ProgressStyle(description_…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "0aa5601e2ac14613bb59caaf8d7a1d8f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Downloading 168:169', max=1, style=ProgressStyle(description_…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "1bff201a70a2431bbb72a2543c050047",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='Downloading 228:229', max=1, style=ProgressStyle(description_…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "{\n",
      "    \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n",
      "    \"definitions\": {\n",
      "        \"float\": {\n",
      "            \"pattern\": \"^-?[0-9]+\\\\.[0-9]{2}$\"\n",
      "        },\n",
      "        \"url\": {\n",
      "            \"pattern\": \"^https?://(www\\\\.)?[a-z0-9.-]*\\\\.[a-z]{2,}([^<>%\\\\x20\\\\x00-\\\\x1f\\\\x7F]|%[0-9a-fA-F]{2})*$\"\n",
      "        }\n",
      "    },\n",
      "    \"additionalProperties\": false,\n",
      "    \"type\": \"object\",\n",
      "    \"properties\": {\n",
      "        \"category\": {\n",
      "            \"type\": \"string\"\n",
      "        },\n",
      "        \"price\": {\n",
      "            \"type\": \"string\"\n",
      "        },\n",
      "        \"_type\": {\n",
      "            \"type\": \"string\"\n",
      "        },\n",
      "        \"description\": {\n",
      "            \"type\": [\n",
      "                \"null\",\n",
      "                \"string\"\n",
      "            ]\n",
      "        },\n",
      "        \"title\": {\n",
      "            \"type\": \"string\"\n",
      "        },\n",
      "        \"_key\": {\n",
      "            \"type\": \"string\"\n",
      "        }\n",
      "    },\n",
      "    \"required\": [\n",
      "        \"_key\",\n",
      "        \"_type\",\n",
      "        \"category\",\n",
      "        \"description\",\n",
      "        \"price\",\n",
      "        \"title\"\n",
      "    ]\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "basic_json_schema(\"235801/1/15\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:01:59.295022Z",
     "start_time": "2019-03-22T21:01:59.285607Z"
    }
   },
   "source": [
    "By itself a basic schema is pretty useless, but you can update it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:02:14.500232Z",
     "start_time": "2019-03-22T21:02:14.452833Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>Field</th>\n",
       "      <th>_key</th>\n",
       "      <th>_type</th>\n",
       "      <th>category</th>\n",
       "      <th>description</th>\n",
       "      <th>price</th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>https://app.scrapinghub.com/p/235801/1/15/item/0</td>\n",
       "      <td>dict</td>\n",
       "      <td>Politics</td>\n",
       "      <td>Libertarianism isn't about winning elections; ...</td>\n",
       "      <td>£51.33</td>\n",
       "      <td>Libertarianism for Beginners</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>https://app.scrapinghub.com/p/235801/1/15/item/1</td>\n",
       "      <td>dict</td>\n",
       "      <td>Poetry</td>\n",
       "      <td>This book is an important and complete collect...</td>\n",
       "      <td>£20.66</td>\n",
       "      <td>Shakespeare's Sonnets</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>https://app.scrapinghub.com/p/235801/1/15/item/2</td>\n",
       "      <td>dict</td>\n",
       "      <td>Young Adult</td>\n",
       "      <td>Aaron Ledbetter’s future had been planned out ...</td>\n",
       "      <td>£17.46</td>\n",
       "      <td>Set Me Free</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>https://app.scrapinghub.com/p/235801/1/15/item/3</td>\n",
       "      <td>dict</td>\n",
       "      <td>Default</td>\n",
       "      <td>Since her assault, Miss Annette Chetwynd has b...</td>\n",
       "      <td>£13.99</td>\n",
       "      <td>Starving Hearts (Triangular Trade Trilogy, #1)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>https://app.scrapinghub.com/p/235801/1/15/item/4</td>\n",
       "      <td>dict</td>\n",
       "      <td>Music</td>\n",
       "      <td>This is the never-before-told story of the mus...</td>\n",
       "      <td>£57.25</td>\n",
       "      <td>Our Band Could Be Your Life: Scenes from the A...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Field                                              _key _type     category  \\\n",
       "0      https://app.scrapinghub.com/p/235801/1/15/item/0  dict     Politics   \n",
       "1      https://app.scrapinghub.com/p/235801/1/15/item/1  dict       Poetry   \n",
       "2      https://app.scrapinghub.com/p/235801/1/15/item/2  dict  Young Adult   \n",
       "3      https://app.scrapinghub.com/p/235801/1/15/item/3  dict      Default   \n",
       "4      https://app.scrapinghub.com/p/235801/1/15/item/4  dict        Music   \n",
       "\n",
       "Field                                        description   price  \\\n",
       "0      Libertarianism isn't about winning elections; ...  £51.33   \n",
       "1      This book is an important and complete collect...  £20.66   \n",
       "2      Aaron Ledbetter’s future had been planned out ...  £17.46   \n",
       "3      Since her assault, Miss Annette Chetwynd has b...  £13.99   \n",
       "4      This is the never-before-told story of the mus...  £57.25   \n",
       "\n",
       "Field                                              title  \n",
       "0                           Libertarianism for Beginners  \n",
       "1                                  Shakespeare's Sonnets  \n",
       "2                                            Set Me Free  \n",
       "3         Starving Hearts (Triangular Trade Trilogy, #1)  \n",
       "4      Our Band Could Be Your Life: Scenes from the A...  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.source_items.df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Looks like `price` can be checked with regex. Let's also add `category` tag which helps to see the distribution in categoric data and `unique` tag to title to ensure there are no duplicates."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:02:15.116277Z",
     "start_time": "2019-03-22T21:02:15.097663Z"
    }
   },
   "outputs": [],
   "source": [
    "a.schema = {\n",
    "    \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n",
    "    \"definitions\": {\n",
    "        \"float\": {\n",
    "            \"pattern\": \"^-?[0-9]+\\\\.[0-9]{2}$\"\n",
    "        },\n",
    "        \"url\": {\n",
    "            \"pattern\": \"^https?://(www\\\\.)?[a-z0-9.-]*\\\\.[a-z]{2,}([^<>%\\\\x20\\\\x00-\\\\x1f\\\\x7F]|%[0-9a-fA-F]{2})*$\"\n",
    "        }\n",
    "    },\n",
    "    \"additionalProperties\": False,\n",
    "    \"type\": \"object\",\n",
    "    \"properties\": {\n",
    "        \"category\": {\"type\": \"string\", \"tag\": [\"category\"]},\n",
    "        \"price\": {\"type\": \"string\", \"pattern\": \"^£\\d{2}.\\d{2}$\"},\n",
    "        \"_type\": {\"type\": \"string\"},\n",
    "        \"description\": {\"type\": \"string\"},\n",
    "        \"title\": {\"type\": \"string\", \"tag\": [\"unique\"]},\n",
    "        \"_key\": {\"type\": \"string\"}\n",
    "    },\n",
    "    \"required\": [\n",
    "        \"_key\",\n",
    "        \"_type\",\n",
    "        \"category\",\n",
    "        \"description\",\n",
    "        \"price\",\n",
    "        \"title\"\n",
    "    ]\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:02:15.808566Z",
     "start_time": "2019-03-22T21:02:15.625333Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d7e0e4b798eb48299f838e89b5038c99",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='JSON Schema Validation', max=1000, style=ProgressStyle(descri…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "RULE: JSON Schema Validation\n",
      "(1 message(s))\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "2 items affected - description is not of type 'string': <a href='https://app.scrapinghub.com/p/235801/1/15/item/980'>980</a> <a href='https://app.scrapinghub.com/p/235801/1/15/item/162'>162</a>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<br>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "a.validate_with_json_schema()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Or if your job is really big you can use almost 100x faster [backend](https://github.com/horejsek/python-fastjsonschema)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "edc1279a218c47c9903fcbeedb9ac528",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='JSON Schema Validation', max=1000, style=ProgressStyle(descri…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "RULE: JSON Schema Validation\n",
      "(1 message(s))\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "2 items affected - data.description must be string: <a href='https://app.scrapinghub.com/p/235801/1/15/item/980'>980</a> <a href='https://app.scrapinghub.com/p/235801/1/15/item/162'>162</a>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<br>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "a.glance()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We already got something! Let's execute the whole thing again to see how `category` tag works."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-03-22T21:02:20.766381Z",
     "start_time": "2019-03-22T21:02:18.838290Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "926d1172179146bbb7970c2edc426e3c",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(IntProgress(value=0, description='JSON Schema Validation', max=1000, style=ProgressStyle(descri…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "Job Outcome:\n",
      "\tFinished\n",
      "\n",
      "Job Errors:\n",
      "\tNo errors\n",
      "\n",
      "Responses Per Item Ratio:\n",
      "\tNumber of responses / Number of scraped items - 1.05\n",
      "\n",
      "Fields Coverage:\n",
      "\t0 totally empty field(s)\n",
      "\n",
      "JSON Schema Validation:\n",
      "\u001b[31m\t1000 items were checked, 1 error(s)\u001b[0m\n",
      "\n",
      "Tags:\n",
      "\tcategory, unique\n",
      "\n",
      "Compare Price Was And Now:\n",
      "\tproduct_price_field or product_price_was_field tags were not found in schema\n",
      "\n",
      "Uniqueness:\n",
      "\u001b[31m\t'title' contains 1 duplicated value(s)\u001b[0m\n",
      "\n",
      "Duplicated Items:\n",
      "\t'name_field' and 'product_url_field' tags were not found in schema\n",
      "\n",
      "Coverage For Scraped Categories:\n",
      "\t50 categories in 'category'\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "RULE: Fields Coverage\n",
      "(1 message(s))\n",
      "\n",
      "             Values Count  Percent\n",
      "Field                             \n",
      "description           998       99\n",
      "_key                 1000      100\n",
      "_type                1000      100\n",
      "category             1000      100\n",
      "price                1000      100\n",
      "title                1000      100\n",
      "\n",
      "RULE: JSON Schema Validation\n",
      "(1 message(s))\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "2 items affected - description is not of type 'string': <a href='https://app.scrapinghub.com/p/235801/1/15/item/980'>980</a> <a href='https://app.scrapinghub.com/p/235801/1/15/item/162'>162</a>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<br>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "RULE: Uniqueness\n",
      "(1 message(s))\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "2 items affected - same 'The Star-Touched Queen' title: <a href='https://app.scrapinghub.com/p/235801/1/15/item/220'>220</a> <a href='https://app.scrapinghub.com/p/235801/1/15/item/396'>396</a>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<br>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "RULE: Coverage For Scraped Categories\n",
      "(1 message(s))\n",
      "\n"
     ]
    },
    {
     "data": {
      "application/vnd.plotly.v1+json": {
       "config": {
        "linkText": "Export to plot.ly",
        "plotlyServerURL": "https://plot.ly",
        "showLink": true
       },
       "data": [
        {
         "marker": {
          "color": "rgba(226, 74, 51, 0.6)",
          "line": {
           "color": "rgba(226, 74, 51, 1.0)",
           "width": 1
          }
         },
         "name": "category",
         "orientation": "h",
         "text": "",
         "type": "bar",
         "uid": "a76b89c2-48de-4a0f-8341-bb8fc2685175",
         "x": [
          152,
          110,
          75,
          67,
          65,
          54,
          48,
          35,
          32,
          30,
          29,
          26,
          19,
          19,
          18,
          17,
          17,
          16,
          14,
          13,
          12,
          11,
          11,
          11,
          10,
          9,
          8,
          7,
          7,
          6,
          6,
          6,
          5,
          5,
          5,
          4,
          3,
          3,
          3,
          2,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1,
          1
         ],
         "y": [
          "Default",
          "Nonfiction",
          "Sequential Art",
          "Add a comment",
          "Fiction",
          "Young Adult",
          "Fantasy",
          "Romance",
          "Mystery",
          "Food and Drink",
          "Childrens",
          "Historical Fiction",
          "Poetry",
          "Classics",
          "History",
          "Horror",
          "Womens Fiction",
          "Science Fiction",
          "Science",
          "Music",
          "Business",
          "Thriller",
          "Travel",
          "Philosophy",
          "Humor",
          "Autobiography",
          "Art",
          "Religion",
          "Psychology",
          "New Adult",
          "Spirituality",
          "Christian Fiction",
          "Self Help",
          "Biography",
          "Sports and Games",
          "Health",
          "Politics",
          "Christian",
          "Contemporary",
          "Historical",
          "Adult Fiction",
          "Crime",
          "Short Stories",
          "Novels",
          "Parenting",
          "Paranormal",
          "Suspense",
          "Academic",
          "Erotica",
          "Cultural"
         ]
        }
       ],
       "layout": {
        "yaxis": {
         "automargin": true,
         "side": "right"
        }
       }
      },
      "text/html": [
       "<div id=\"25cdd146-6803-46b9-aa23-210c93b5cf37\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
       "if (document.getElementById(\"25cdd146-6803-46b9-aa23-210c93b5cf37\")) {\n",
       "    Plotly.newPlot(\"25cdd146-6803-46b9-aa23-210c93b5cf37\", [{\"marker\": {\"color\": \"rgba(226, 74, 51, 0.6)\", \"line\": {\"color\": \"rgba(226, 74, 51, 1.0)\", \"width\": 1}}, \"name\": \"category\", \"orientation\": \"h\", \"text\": \"\", \"x\": [152, 110, 75, 67, 65, 54, 48, 35, 32, 30, 29, 26, 19, 19, 18, 17, 17, 16, 14, 13, 12, 11, 11, 11, 10, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 4, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"y\": [\"Default\", \"Nonfiction\", \"Sequential Art\", \"Add a comment\", \"Fiction\", \"Young Adult\", \"Fantasy\", \"Romance\", \"Mystery\", \"Food and Drink\", \"Childrens\", \"Historical Fiction\", \"Poetry\", \"Classics\", \"History\", \"Horror\", \"Womens Fiction\", \"Science Fiction\", \"Science\", \"Music\", \"Business\", \"Thriller\", \"Travel\", \"Philosophy\", \"Humor\", \"Autobiography\", \"Art\", \"Religion\", \"Psychology\", \"New Adult\", \"Spirituality\", \"Christian Fiction\", \"Self Help\", \"Biography\", \"Sports and Games\", \"Health\", \"Politics\", \"Christian\", \"Contemporary\", \"Historical\", \"Adult Fiction\", \"Crime\", \"Short Stories\", \"Novels\", \"Parenting\", \"Paranormal\", \"Suspense\", \"Academic\", \"Erotica\", \"Cultural\"], \"type\": \"bar\", \"uid\": \"429254cb-bedf-4786-8cdc-34675e4f24b6\"}], {\"yaxis\": {\"automargin\": true, \"side\": \"right\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
       "}\n",
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"25cdd146-6803-46b9-aa23-210c93b5cf37\")) {window._Plotly.Plots.resize(document.getElementById(\"25cdd146-6803-46b9-aa23-210c93b5cf37\"));};})</script>"
      ],
      "text/vnd.plotly.v1+html": [
       "<div id=\"25cdd146-6803-46b9-aa23-210c93b5cf37\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
       "if (document.getElementById(\"25cdd146-6803-46b9-aa23-210c93b5cf37\")) {\n",
       "    Plotly.newPlot(\"25cdd146-6803-46b9-aa23-210c93b5cf37\", [{\"marker\": {\"color\": \"rgba(226, 74, 51, 0.6)\", \"line\": {\"color\": \"rgba(226, 74, 51, 1.0)\", \"width\": 1}}, \"name\": \"category\", \"orientation\": \"h\", \"text\": \"\", \"x\": [152, 110, 75, 67, 65, 54, 48, 35, 32, 30, 29, 26, 19, 19, 18, 17, 17, 16, 14, 13, 12, 11, 11, 11, 10, 9, 8, 7, 7, 6, 6, 6, 5, 5, 5, 4, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], \"y\": [\"Default\", \"Nonfiction\", \"Sequential Art\", \"Add a comment\", \"Fiction\", \"Young Adult\", \"Fantasy\", \"Romance\", \"Mystery\", \"Food and Drink\", \"Childrens\", \"Historical Fiction\", \"Poetry\", \"Classics\", \"History\", \"Horror\", \"Womens Fiction\", \"Science Fiction\", \"Science\", \"Music\", \"Business\", \"Thriller\", \"Travel\", \"Philosophy\", \"Humor\", \"Autobiography\", \"Art\", \"Religion\", \"Psychology\", \"New Adult\", \"Spirituality\", \"Christian Fiction\", \"Self Help\", \"Biography\", \"Sports and Games\", \"Health\", \"Politics\", \"Christian\", \"Contemporary\", \"Historical\", \"Adult Fiction\", \"Crime\", \"Short Stories\", \"Novels\", \"Parenting\", \"Paranormal\", \"Suspense\", \"Academic\", \"Erotica\", \"Cultural\"], \"type\": \"bar\", \"uid\": \"429254cb-bedf-4786-8cdc-34675e4f24b6\"}], {\"yaxis\": {\"automargin\": true, \"side\": \"right\"}}, {\"showLink\": true, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
       "}\n",
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"25cdd146-6803-46b9-aa23-210c93b5cf37\")) {window._Plotly.Plots.resize(document.getElementById(\"25cdd146-6803-46b9-aa23-210c93b5cf37\"));};})</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "a.report_all()"
   ]
  }
 ],
 "metadata": {
  "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.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
