diff --git a/examples/Basic Usage.ipynb b/examples/Basic Usage.ipynb
new file mode 100644
index 000000000..d12393c21
--- /dev/null
+++ b/examples/Basic Usage.ipynb
@@ -0,0 +1,710 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Basic cartoframes functionality"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import cartoframes\n",
+ "from cartoframes.credentials import set_credentials\n",
+ "import pandas as pd\n",
+ "\n",
+ "# BASEURL are in the format:\n",
+ "# https://USERNAME.carto.com -- for all cloud users, even if in a multiuser organization\n",
+ "# for on premise installs, contact your admin\n",
+ "BASEURL = 'https://eschbacher.carto.com' # <-- replace with your username \n",
+ "APIKEY = 'abcdefghijklmnopqrstuvwxyz' # <-- your CARTO API key\n",
+ "set_credentials(base_url=BASEURL, api_key=APIKEY, overwrite=True)\n",
+ "\n",
+ "cc = cartoframes.CartoContext()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " the_geom | \n",
+ " the_geom_webmercator | \n",
+ " geoid | \n",
+ " poverty_count | \n",
+ " total_population | \n",
+ " poverty_per_pop | \n",
+ " total_pop_2011_2015 | \n",
+ " pop_determined_poverty_status_2011_2015 | \n",
+ " commuters_16_over_2011_2015 | \n",
+ " walked_to_work_2011_2015 | \n",
+ "
\n",
+ " \n",
+ " cartodb_id | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ " | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 2 | \n",
+ " 0103000020E6100000010000000B0000006D3A02B85982... | \n",
+ " 0103000020110F0000010000000B000000D240DAA89070... | \n",
+ " 360470050003 | \n",
+ " 23.112583 | \n",
+ " 741.0 | \n",
+ " 0.031191 | \n",
+ " 9624.365242 | \n",
+ " 3304.439797 | \n",
+ " 4074.192637 | \n",
+ " 0.005207 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 0103000020E610000001000000090000006AA164726A80... | \n",
+ " 0103000020110F000001000000090000009188EE63476D... | \n",
+ " 360470108003 | \n",
+ " 818.804124 | \n",
+ " 2067.0 | \n",
+ " 0.396132 | \n",
+ " 35743.802143 | \n",
+ " 28261.979968 | \n",
+ " 16316.285548 | \n",
+ " 0.016649 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 0103000020E6100000010000000E000000591822A7AF7F... | \n",
+ " 0103000020110F0000010000000E000000F2591B1A0A6C... | \n",
+ " 360470110001 | \n",
+ " 237.985714 | \n",
+ " 1306.0 | \n",
+ " 0.182225 | \n",
+ " 12959.090059 | \n",
+ " 17101.367690 | \n",
+ " 4429.434939 | \n",
+ " 0.021986 | \n",
+ "
\n",
+ " \n",
+ " 6 | \n",
+ " 0103000020E61000000100000008000000F5BD86E0B87E... | \n",
+ " 0103000020110F000001000000080000009110AEED666A... | \n",
+ " 360470129012 | \n",
+ " 57.217391 | \n",
+ " 1143.0 | \n",
+ " 0.050059 | \n",
+ " 26191.505928 | \n",
+ " 18825.265007 | \n",
+ " 16044.550829 | \n",
+ " 0.009637 | \n",
+ "
\n",
+ " \n",
+ " 7 | \n",
+ " 0103000020E6100000010000000C000000E6CDE15AED7E... | \n",
+ " 0103000020110F0000010000000C0000008FF54811C06A... | \n",
+ " 360470169003 | \n",
+ " 0.000000 | \n",
+ " 572.0 | \n",
+ " 0.000000 | \n",
+ " 11023.184048 | \n",
+ " 22815.245110 | \n",
+ " 7607.777537 | \n",
+ " 0.010880 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " the_geom \\\n",
+ "cartodb_id \n",
+ "2 0103000020E6100000010000000B0000006D3A02B85982... \n",
+ "3 0103000020E610000001000000090000006AA164726A80... \n",
+ "4 0103000020E6100000010000000E000000591822A7AF7F... \n",
+ "6 0103000020E61000000100000008000000F5BD86E0B87E... \n",
+ "7 0103000020E6100000010000000C000000E6CDE15AED7E... \n",
+ "\n",
+ " the_geom_webmercator geoid \\\n",
+ "cartodb_id \n",
+ "2 0103000020110F0000010000000B000000D240DAA89070... 360470050003 \n",
+ "3 0103000020110F000001000000090000009188EE63476D... 360470108003 \n",
+ "4 0103000020110F0000010000000E000000F2591B1A0A6C... 360470110001 \n",
+ "6 0103000020110F000001000000080000009110AEED666A... 360470129012 \n",
+ "7 0103000020110F0000010000000C0000008FF54811C06A... 360470169003 \n",
+ "\n",
+ " poverty_count total_population poverty_per_pop \\\n",
+ "cartodb_id \n",
+ "2 23.112583 741.0 0.031191 \n",
+ "3 818.804124 2067.0 0.396132 \n",
+ "4 237.985714 1306.0 0.182225 \n",
+ "6 57.217391 1143.0 0.050059 \n",
+ "7 0.000000 572.0 0.000000 \n",
+ "\n",
+ " total_pop_2011_2015 pop_determined_poverty_status_2011_2015 \\\n",
+ "cartodb_id \n",
+ "2 9624.365242 3304.439797 \n",
+ "3 35743.802143 28261.979968 \n",
+ "4 12959.090059 17101.367690 \n",
+ "6 26191.505928 18825.265007 \n",
+ "7 11023.184048 22815.245110 \n",
+ "\n",
+ " commuters_16_over_2011_2015 walked_to_work_2011_2015 \n",
+ "cartodb_id \n",
+ "2 4074.192637 0.005207 \n",
+ "3 16316.285548 0.016649 \n",
+ "4 4429.434939 0.021986 \n",
+ "6 16044.550829 0.009637 \n",
+ "7 7607.777537 0.010880 "
+ ]
+ },
+ "execution_count": 2,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Get a CARTO table as a pandas DataFrame\n",
+ "df = cc.read('brooklyn_poverty')\n",
+ "df.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "scrolled": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "from cartoframes import Layer, styling\n",
+ "l = Layer('brooklyn_poverty', color={'column': 'poverty_per_pop', 'scheme': styling.sunset(7)})\n",
+ "cc.map(layers=l, interactive=False)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " VendorID | \n",
+ " tpep_pickup_datetime | \n",
+ " tpep_dropoff_datetime | \n",
+ " passenger_count | \n",
+ " trip_distance | \n",
+ " pickup_longitude | \n",
+ " pickup_latitude | \n",
+ " RatecodeID | \n",
+ " store_and_fwd_flag | \n",
+ " dropoff_longitude | \n",
+ " dropoff_latitude | \n",
+ " payment_type | \n",
+ " fare_amount | \n",
+ " extra | \n",
+ " mta_tax | \n",
+ " tip_amount | \n",
+ " tolls_amount | \n",
+ " improvement_surcharge | \n",
+ " total_amount | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 2 | \n",
+ " 2016-05-01 14:52:11 | \n",
+ " 2016-05-01 15:00:36 | \n",
+ " 2 | \n",
+ " 2.08 | \n",
+ " -74.006706 | \n",
+ " 40.730461 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -74.012383 | \n",
+ " 40.706779 | \n",
+ " 1.0 | \n",
+ " 8.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 1.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 10.30 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 2016-05-01 08:34:08 | \n",
+ " 2016-05-01 08:49:02 | \n",
+ " 1 | \n",
+ " 3.00 | \n",
+ " -73.924957 | \n",
+ " 40.744125 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.973824 | \n",
+ " 40.762779 | \n",
+ " 1.0 | \n",
+ " 13.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 2.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 16.30 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 1 | \n",
+ " 2016-05-04 09:44:40 | \n",
+ " 2016-05-04 10:07:09 | \n",
+ " 1 | \n",
+ " 2.10 | \n",
+ " -73.973488 | \n",
+ " 40.748501 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.998955 | \n",
+ " 40.740833 | \n",
+ " 2.0 | \n",
+ " 14.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 0.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 15.30 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 2 | \n",
+ " 2016-05-01 20:50:11 | \n",
+ " 2016-05-01 21:05:24 | \n",
+ " 1 | \n",
+ " 4.41 | \n",
+ " -73.999786 | \n",
+ " 40.743267 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.966362 | \n",
+ " 40.792370 | \n",
+ " 2.0 | \n",
+ " 15.0 | \n",
+ " 0.5 | \n",
+ " 0.5 | \n",
+ " 0.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 16.30 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 2 | \n",
+ " 2016-05-02 07:26:56 | \n",
+ " 2016-05-02 07:53:53 | \n",
+ " 2 | \n",
+ " 4.01 | \n",
+ " -73.963631 | \n",
+ " 40.803360 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.956963 | \n",
+ " 40.784939 | \n",
+ " 1.0 | \n",
+ " 19.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 4.06 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 24.36 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " VendorID tpep_pickup_datetime tpep_dropoff_datetime passenger_count \\\n",
+ "0 2 2016-05-01 14:52:11 2016-05-01 15:00:36 2 \n",
+ "1 1 2016-05-01 08:34:08 2016-05-01 08:49:02 1 \n",
+ "2 1 2016-05-04 09:44:40 2016-05-04 10:07:09 1 \n",
+ "3 2 2016-05-01 20:50:11 2016-05-01 21:05:24 1 \n",
+ "4 2 2016-05-02 07:26:56 2016-05-02 07:53:53 2 \n",
+ "\n",
+ " trip_distance pickup_longitude pickup_latitude RatecodeID \\\n",
+ "0 2.08 -74.006706 40.730461 1.0 \n",
+ "1 3.00 -73.924957 40.744125 1.0 \n",
+ "2 2.10 -73.973488 40.748501 1.0 \n",
+ "3 4.41 -73.999786 40.743267 1.0 \n",
+ "4 4.01 -73.963631 40.803360 1.0 \n",
+ "\n",
+ " store_and_fwd_flag dropoff_longitude dropoff_latitude payment_type \\\n",
+ "0 N -74.012383 40.706779 1.0 \n",
+ "1 N -73.973824 40.762779 1.0 \n",
+ "2 N -73.998955 40.740833 2.0 \n",
+ "3 N -73.966362 40.792370 2.0 \n",
+ "4 N -73.956963 40.784939 1.0 \n",
+ "\n",
+ " fare_amount extra mta_tax tip_amount tolls_amount \\\n",
+ "0 8.5 0.0 0.5 1.00 0.0 \n",
+ "1 13.5 0.0 0.5 2.00 0.0 \n",
+ "2 14.5 0.0 0.5 0.00 0.0 \n",
+ "3 15.0 0.5 0.5 0.00 0.0 \n",
+ "4 19.5 0.0 0.5 4.06 0.0 \n",
+ "\n",
+ " improvement_surcharge total_amount \n",
+ "0 0.3 10.30 \n",
+ "1 0.3 16.30 \n",
+ "2 0.3 15.30 \n",
+ "3 0.3 16.30 \n",
+ "4 0.3 24.36 "
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# read in a CSV of NYC taxi data\n",
+ "df = pd.read_csv('taxi_sample.csv')\n",
+ "df.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " VendorID | \n",
+ " tpep_pickup_datetime | \n",
+ " tpep_dropoff_datetime | \n",
+ " passenger_count | \n",
+ " trip_distance | \n",
+ " pickup_longitude | \n",
+ " pickup_latitude | \n",
+ " RatecodeID | \n",
+ " store_and_fwd_flag | \n",
+ " dropoff_longitude | \n",
+ " dropoff_latitude | \n",
+ " payment_type | \n",
+ " fare_amount | \n",
+ " extra | \n",
+ " mta_tax | \n",
+ " tip_amount | \n",
+ " tolls_amount | \n",
+ " improvement_surcharge | \n",
+ " total_amount | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 2 | \n",
+ " 2016-05-01 14:52:11 | \n",
+ " 2016-05-01 15:00:36 | \n",
+ " 2 | \n",
+ " 2.08 | \n",
+ " -74.006706 | \n",
+ " 40.730461 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -74.012383 | \n",
+ " 40.706779 | \n",
+ " 1.0 | \n",
+ " 8.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 1.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 10.30 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 1 | \n",
+ " 2016-05-01 08:34:08 | \n",
+ " 2016-05-01 08:49:02 | \n",
+ " 1 | \n",
+ " 3.00 | \n",
+ " -73.924957 | \n",
+ " 40.744125 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.973824 | \n",
+ " 40.762779 | \n",
+ " 1.0 | \n",
+ " 13.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 2.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 16.30 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 1 | \n",
+ " 2016-05-04 09:44:40 | \n",
+ " 2016-05-04 10:07:09 | \n",
+ " 1 | \n",
+ " 2.10 | \n",
+ " -73.973488 | \n",
+ " 40.748501 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.998955 | \n",
+ " 40.740833 | \n",
+ " 2.0 | \n",
+ " 14.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 0.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 15.30 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 2 | \n",
+ " 2016-05-01 20:50:11 | \n",
+ " 2016-05-01 21:05:24 | \n",
+ " 1 | \n",
+ " 4.41 | \n",
+ " -73.999786 | \n",
+ " 40.743267 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.966362 | \n",
+ " 40.792370 | \n",
+ " 2.0 | \n",
+ " 15.0 | \n",
+ " 0.5 | \n",
+ " 0.5 | \n",
+ " 0.00 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 16.30 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 2 | \n",
+ " 2016-05-02 07:26:56 | \n",
+ " 2016-05-02 07:53:53 | \n",
+ " 2 | \n",
+ " 4.01 | \n",
+ " -73.963631 | \n",
+ " 40.803360 | \n",
+ " 1.0 | \n",
+ " N | \n",
+ " -73.956963 | \n",
+ " 40.784939 | \n",
+ " 1.0 | \n",
+ " 19.5 | \n",
+ " 0.0 | \n",
+ " 0.5 | \n",
+ " 4.06 | \n",
+ " 0.0 | \n",
+ " 0.3 | \n",
+ " 24.36 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " VendorID tpep_pickup_datetime tpep_dropoff_datetime passenger_count \\\n",
+ "0 2 2016-05-01 14:52:11 2016-05-01 15:00:36 2 \n",
+ "1 1 2016-05-01 08:34:08 2016-05-01 08:49:02 1 \n",
+ "2 1 2016-05-04 09:44:40 2016-05-04 10:07:09 1 \n",
+ "3 2 2016-05-01 20:50:11 2016-05-01 21:05:24 1 \n",
+ "4 2 2016-05-02 07:26:56 2016-05-02 07:53:53 2 \n",
+ "\n",
+ " trip_distance pickup_longitude pickup_latitude RatecodeID \\\n",
+ "0 2.08 -74.006706 40.730461 1.0 \n",
+ "1 3.00 -73.924957 40.744125 1.0 \n",
+ "2 2.10 -73.973488 40.748501 1.0 \n",
+ "3 4.41 -73.999786 40.743267 1.0 \n",
+ "4 4.01 -73.963631 40.803360 1.0 \n",
+ "\n",
+ " store_and_fwd_flag dropoff_longitude dropoff_latitude payment_type \\\n",
+ "0 N -74.012383 40.706779 1.0 \n",
+ "1 N -73.973824 40.762779 1.0 \n",
+ "2 N -73.998955 40.740833 2.0 \n",
+ "3 N -73.966362 40.792370 2.0 \n",
+ "4 N -73.956963 40.784939 1.0 \n",
+ "\n",
+ " fare_amount extra mta_tax tip_amount tolls_amount \\\n",
+ "0 8.5 0.0 0.5 1.00 0.0 \n",
+ "1 13.5 0.0 0.5 2.00 0.0 \n",
+ "2 14.5 0.0 0.5 0.00 0.0 \n",
+ "3 15.0 0.5 0.5 0.00 0.0 \n",
+ "4 19.5 0.0 0.5 4.06 0.0 \n",
+ "\n",
+ " improvement_surcharge total_amount \n",
+ "0 0.3 10.30 \n",
+ "1 0.3 16.30 \n",
+ "2 0.3 15.30 \n",
+ "3 0.3 16.30 \n",
+ "4 0.3 24.36 "
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# send it to carto so we can map it\n",
+ "cc.write(df, 'taxi_sample',\n",
+ " lnglat=('pickup_longitude', 'pickup_latitude'),\n",
+ " overwrite=True)\n",
+ "df.head()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "from cartoframes import Layer\n",
+ "cc.map(layers=Layer('taxi_sample'),\n",
+ " interactive=False)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Oops, there are some zero-valued long/lats in there, so the results are going to [null island](https://en.wikipedia.org/wiki/Null_Island). Let's remove them."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "df = df[(df['pickup_longitude'] != 0) | (df['pickup_latitude'] != 0)]\n",
+ "cc.write(df, 'taxi_sample', overwrite=True,\n",
+ " lnglat=('pickup_longitude', 'pickup_latitude'))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 8,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "# Let's take a look at what's going on at JFK airport, styled by the fare amount\n",
+ "cc.map(layers=Layer('taxi_sample',\n",
+ " size=4,\n",
+ " color={'column': 'fare_amount',\n",
+ " 'scheme': styling.sunset(7)}),\n",
+ " zoom=12, lng=-73.7880, lat=40.6629,\n",
+ " interactive=False)"
+ ]
+ }
+ ],
+ "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.1"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/examples/cartoframes demos.ipynb b/examples/cartoframes demos.ipynb
deleted file mode 100644
index d73bc82de..000000000
--- a/examples/cartoframes demos.ipynb
+++ /dev/null
@@ -1,270 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# cartoframes demo"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 14,
- "metadata": {
- "collapsed": false,
- "scrolled": true
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- ""
- ]
- },
- "execution_count": 14,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "reload(cartoframes)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 15,
- "metadata": {
- "collapsed": false
- },
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "import carto\n",
- "import cartoframes\n",
- "\n",
- "import json\n",
- "from carto.auth import APIKeyAuthClient\n",
- "\n",
- "creds = json.loads(open('credentials.json').read())\n",
- "API_KEY = creds['api_key']\n",
- "USERNAME = creds['username']\n",
- "BASEURL = 'https://{username}.carto.com/api/'.format(username=USERNAME)\n",
- "\n",
- "auth_client = APIKeyAuthClient(BASEURL, API_KEY)"
- ]
- },
- {
- "cell_type": "raw",
- "metadata": {},
- "source": [
- "# brooklyn_poverty poverty_per_pop\n",
- "# dsny_monthly_tonnage_data\n",
- "# us_counties pop_sqkm\n",
- "# ny_boroughs boroname"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Grab dataset"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 16,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
\n",
- " \n",
- " \n",
- " | \n",
- " geoid | \n",
- " poverty_count | \n",
- " poverty_per_pop | \n",
- " the_geom | \n",
- " the_geom_webmercator | \n",
- " total_population | \n",
- "
\n",
- " \n",
- " cartodb_id | \n",
- " | \n",
- " | \n",
- " | \n",
- " | \n",
- " | \n",
- " | \n",
- "
\n",
- " \n",
- " \n",
- " \n",
- " 34 | \n",
- " 360470341002 | \n",
- " 100.682065 | \n",
- " 0.135144 | \n",
- " 0103000020E61000000100000005000000D784B4C6A07C... | \n",
- " 0103000020110F00000100000005000000D0DEA24ED866... | \n",
- " 745.0 | \n",
- "
\n",
- " \n",
- " 1 | \n",
- " 360470043001 | \n",
- " 0.000000 | \n",
- " NaN | \n",
- " 0103000020E6100000010000000700000037FC6EBA657F... | \n",
- " 0103000020110F00000100000007000000B7A199888C6B... | \n",
- " 140.0 | \n",
- "
\n",
- " \n",
- " 102 | \n",
- " 360470510023 | \n",
- " 260.500000 | \n",
- " 0.216542 | \n",
- " 0103000020E610000001000000050000002D78D157907D... | \n",
- " 0103000020110F0000010000000500000093664E3C6F68... | \n",
- " 1203.0 | \n",
- "
\n",
- " \n",
- " 49 | \n",
- " 360470406002 | \n",
- " 106.907834 | \n",
- " 0.167567 | \n",
- " 0103000020E6100000010000000700000021E9D32AFA7E... | \n",
- " 0103000020110F00000100000007000000D4559AD4D56A... | \n",
- " 638.0 | \n",
- "
\n",
- " \n",
- " 69 | \n",
- " 360470510011 | \n",
- " 270.728785 | \n",
- " 0.130724 | \n",
- " 0103000020E61000000100000006000000A65EB7088C7D... | \n",
- " 0103000020110F00000100000006000000FC9A93EA6768... | \n",
- " 2071.0 | \n",
- "
\n",
- " \n",
- "
\n",
- "
"
- ],
- "text/plain": [
- " geoid poverty_count poverty_per_pop \\\n",
- "cartodb_id \n",
- "34 360470341002 100.682065 0.135144 \n",
- "1 360470043001 0.000000 NaN \n",
- "102 360470510023 260.500000 0.216542 \n",
- "49 360470406002 106.907834 0.167567 \n",
- "69 360470510011 270.728785 0.130724 \n",
- "\n",
- " the_geom \\\n",
- "cartodb_id \n",
- "34 0103000020E61000000100000005000000D784B4C6A07C... \n",
- "1 0103000020E6100000010000000700000037FC6EBA657F... \n",
- "102 0103000020E610000001000000050000002D78D157907D... \n",
- "49 0103000020E6100000010000000700000021E9D32AFA7E... \n",
- "69 0103000020E61000000100000006000000A65EB7088C7D... \n",
- "\n",
- " the_geom_webmercator \\\n",
- "cartodb_id \n",
- "34 0103000020110F00000100000005000000D0DEA24ED866... \n",
- "1 0103000020110F00000100000007000000B7A199888C6B... \n",
- "102 0103000020110F0000010000000500000093664E3C6F68... \n",
- "49 0103000020110F00000100000007000000D4559AD4D56A... \n",
- "69 0103000020110F00000100000006000000FC9A93EA6768... \n",
- "\n",
- " total_population \n",
- "cartodb_id \n",
- "34 745.0 \n",
- "1 140.0 \n",
- "102 1203.0 \n",
- "49 638.0 \n",
- "69 2071.0 "
- ]
- },
- "execution_count": 16,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "df = pd.read_carto(auth_client, tablename='brooklyn_poverty')\n",
- "df.head()"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Perform operations on dataset"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Map results"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 18,
- "metadata": {
- "collapsed": false,
- "scrolled": false
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- ""
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 18,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "df.carto_map(interactive=True, stylecol='poverty_per_pop')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 2",
- "language": "python",
- "name": "python2"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 2
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython2",
- "version": "2.7.10"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}