{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Upload data to CARTO\n", "\n", "This example illustrates how to upload local data to a CARTO account.\n", "\n", "_Note: You'll need [CARTO Account](https://carto.com/signup) credentials to reproduce this example._" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from cartoframes.auth import set_default_credentials\n", "\n", "set_default_credentials('creds.json')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cartodb_idthe_geomfield_1nameaddressrevenue
01POINT (-73.95901 40.67109)0Franklin Ave & Eastern Pkwy341 Eastern Pkwy,Brooklyn, NY 112381321040.772
12POINT (-73.96122 40.57796)1607 Brighton Beach Ave607 Brighton Beach Avenue,Brooklyn, NY 112351268080.418
23POINT (-73.98976 40.61912)265th St & 18th Ave6423 18th Avenue,Brooklyn, NY 112041248133.699
\n", "
" ], "text/plain": [ " cartodb_id the_geom field_1 \\\n", "0 1 POINT (-73.95901 40.67109) 0 \n", "1 2 POINT (-73.96122 40.57796) 1 \n", "2 3 POINT (-73.98976 40.61912) 2 \n", "\n", " name address \\\n", "0 Franklin Ave & Eastern Pkwy 341 Eastern Pkwy,Brooklyn, NY 11238 \n", "1 607 Brighton Beach Ave 607 Brighton Beach Avenue,Brooklyn, NY 11235 \n", "2 65th St & 18th Ave 6423 18th Avenue,Brooklyn, NY 11204 \n", "\n", " revenue \n", "0 1321040.772 \n", "1 1268080.418 \n", "2 1248133.699 " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cartoframes import read_carto\n", "\n", "gdf = read_carto(\"SELECT * FROM starbucks_brooklyn WHERE revenue > 1200000\")\n", "gdf.head()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Success! Data uploaded to table \"starbucks_brooklyn_filtered\" correctly\n" ] }, { "data": { "text/plain": [ "'starbucks_brooklyn_filtered'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cartoframes import to_carto\n", "\n", "to_carto(gdf, 'starbucks_brooklyn_filtered', if_exists='replace')" ] } ], "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.7" } }, "nbformat": 4, "nbformat_minor": 2 }