{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import floatview\n",
    "import pandas as pd\n",
    "import requests\n",
    "import io\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Warning, each yellow_tripdata dataset is around 1Gb size"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "url=\"https://s3.amazonaws.com/nyc-tlc/trip+data/yellow_tripdata_2018-01.csv\"\n",
    "url=\"https://s3.amazonaws.com/nyc-tlc/trip+data/green_tripdata_2018-01.csv\"\n",
    "s=requests.get(url).content\n",
    "cols = ['passenger_count', 'trip_distance', 'PULocationID', 'DOLocationID', 'total_amount', 'payment_type']\n",
    "tab = pd.read_csv(io.StringIO(s.decode('utf-8')), index_col=False, usecols=cols)\n",
    "tab = tab[(tab['PULocationID'] > 145) & (tab['PULocationID'] < 150)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gmw = floatview.GlueManagerWidget(tab, modal=True, label=\"NYTaxis\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gmw.gluemanager.updateSelection(np.nonzero((gmw.gluemanager.data['passenger_count'] == 4)))\n",
    "gmw.gluemanager.createSubsetFromSelection(label=\"4Passengers\")\n",
    "gmw.gluemanager.updateSelection(np.nonzero((gmw.gluemanager.data['passenger_count'] == 2)))\n",
    "gmw.gluemanager.createSubsetFromSelection(label=\"2Passengers\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "        <script type=\"text/javascript\">\n",
       "        window.PlotlyConfig = {MathJaxConfig: 'local'};\n",
       "        if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}\n",
       "        if (typeof require !== 'undefined') {\n",
       "        require.undef(\"plotly\");\n",
       "        requirejs.config({\n",
       "            paths: {\n",
       "                'plotly': ['https://cdn.plot.ly/plotly-latest.min']\n",
       "            }\n",
       "        });\n",
       "        require(['plotly'], function(Plotly) {\n",
       "            window._Plotly = Plotly;\n",
       "        });\n",
       "        }\n",
       "        </script>\n",
       "        "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "view = gmw.gluemanager.newView(\n",
    "    \"composed_scatter\", \n",
    "    [\"trip_distance\", \"payment_type\", 'passenger_count'], \n",
    "    \"Scatter\"\n",
    ");\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
