{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Data Management\n", "\n", "In this guide you will learn how to load different data files into DataFrames and how to interact with the CARTO platform to upload DataFrames into tables and download tables or SQL queries into DataFrames.\n", "\n", "CARTOframes is built on top of [Pandas](https://pandas.pydata.org/) and [GeoPandas](https://geopandas.org/). Therefore, it's compatible with all the data formats supported in those projects like GeoJSON, Shapefile, CSV, etc.\n", "\n", "There are two main concepts we should know before continuing with the guide:\n", "- A [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) is a two-dimensional data structure for generic data. It can be thought of as a table with rows and columns. It's composed of [Series](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html) objects, which are one-dimensional data structures.\n", "- A [GeoDataFrame](https://geopandas.org/data_structures.html#geodataframe) is a DataFrame with an extra geometry column. This geometry column is a [GeoSeries](https://geopandas.org/data_structures.html#geoseries) object.\n", "\n", "Every time we manage geographic data, a GeoDataFrame should be used. In case a DataFrame with an encoded geometry column is used (WKB, WKT, etc.), every method contains a `geom_col` param to provide the name of that column and decode the geometry internally.\n", "\n", "For further learning you can checkout the [Data Management examples](/developers/cartoframes/examples/#example-data-management)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read a GeoJSON file\n", "\n", "This is how to load geographic data from a GeoJSON file using [GeoPandas](https://geopandas.org/). To read pure JSON files check this [example](/developers/cartoframes/examples/#example-read-a-json-file)." ] }, { "cell_type": "code", "execution_count": 1, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cartodb_idfield_1nameaddressrevenuegeometry
010Franklin Ave & Eastern Pkwy341 Eastern Pkwy,Brooklyn, NY 112381321040.772POINT (-73.95901 40.67109)
121607 Brighton Beach Ave607 Brighton Beach Avenue,Brooklyn, NY 112351268080.418POINT (-73.96122 40.57796)
23265th St & 18th Ave6423 18th Avenue,Brooklyn, NY 112041248133.699POINT (-73.98976 40.61912)
343Bay Ridge Pkwy & 3rd Ave7419 3rd Avenue,Brooklyn, NY 112091185702.676POINT (-74.02744 40.63152)
454Caesar's Bay Shopping Center8973 Bay Parkway,Brooklyn, NY 112141148427.411POINT (-74.00098 40.59321)
\n", "
" ], "text/plain": [ " cartodb_id field_1 name \\\n", "0 1 0 Franklin Ave & Eastern Pkwy \n", "1 2 1 607 Brighton Beach Ave \n", "2 3 2 65th St & 18th Ave \n", "3 4 3 Bay Ridge Pkwy & 3rd Ave \n", "4 5 4 Caesar's Bay Shopping Center \n", "\n", " address revenue \\\n", "0 341 Eastern Pkwy,Brooklyn, NY 11238 1321040.772 \n", "1 607 Brighton Beach Avenue,Brooklyn, NY 11235 1268080.418 \n", "2 6423 18th Avenue,Brooklyn, NY 11204 1248133.699 \n", "3 7419 3rd Avenue,Brooklyn, NY 11209 1185702.676 \n", "4 8973 Bay Parkway,Brooklyn, NY 11214 1148427.411 \n", "\n", " geometry \n", "0 POINT (-73.95901 40.67109) \n", "1 POINT (-73.96122 40.57796) \n", "2 POINT (-73.98976 40.61912) \n", "3 POINT (-74.02744 40.63152) \n", "4 POINT (-74.00098 40.59321) " ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from geopandas import read_file\n", "\n", "gdf = read_file('https://libs.cartocdn.com/cartoframes/samples/starbucks_brooklyn_geocoded.geojson')\n", "gdf.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read a Shapefile\n", "\n", "Shapefile is a complex format, compared to CSV or GeoJSON. To learn more about this format check [GeoPandas documentation](https://geopandas.org/io.html#reading-spatial-data)." ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cartodb_idfield_1nameaddressrevenuegeometry
010Franklin Ave & Eastern Pkwy341 Eastern Pkwy,Brooklyn, NY 112381321040.772POINT (-73.95901 40.67109)
121607 Brighton Beach Ave607 Brighton Beach Avenue,Brooklyn, NY 112351268080.418POINT (-73.96122 40.57796)
23265th St & 18th Ave6423 18th Avenue,Brooklyn, NY 112041248133.699POINT (-73.98976 40.61912)
343Bay Ridge Pkwy & 3rd Ave7419 3rd Avenue,Brooklyn, NY 112091185702.676POINT (-74.02744 40.63152)
454Caesar's Bay Shopping Center8973 Bay Parkway,Brooklyn, NY 112141148427.411POINT (-74.00098 40.59321)
\n", "
" ], "text/plain": [ " cartodb_id field_1 name \\\n", "0 1 0 Franklin Ave & Eastern Pkwy \n", "1 2 1 607 Brighton Beach Ave \n", "2 3 2 65th St & 18th Ave \n", "3 4 3 Bay Ridge Pkwy & 3rd Ave \n", "4 5 4 Caesar's Bay Shopping Center \n", "\n", " address revenue \\\n", "0 341 Eastern Pkwy,Brooklyn, NY 11238 1321040.772 \n", "1 607 Brighton Beach Avenue,Brooklyn, NY 11235 1268080.418 \n", "2 6423 18th Avenue,Brooklyn, NY 11204 1248133.699 \n", "3 7419 3rd Avenue,Brooklyn, NY 11209 1185702.676 \n", "4 8973 Bay Parkway,Brooklyn, NY 11214 1148427.411 \n", "\n", " geometry \n", "0 POINT (-73.95901 40.67109) \n", "1 POINT (-73.96122 40.57796) \n", "2 POINT (-73.98976 40.61912) \n", "3 POINT (-74.02744 40.63152) \n", "4 POINT (-74.00098 40.59321) " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from geopandas import read_file\n", "\n", "gdf = read_file('https://libs.cartocdn.com/cartoframes/samples/starbucks_brooklyn_geocoded.zip')\n", "gdf.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read a CSV file" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Compute geometry from longitude and latitude**" ] }, { "cell_type": "code", "execution_count": 3, "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", " \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", " \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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
incident_datetimeincident_dateincident_timeincident_yearincident_day_of_weekreport_datetimerow_idincident_idincident_numbercad_number...:@computed_region_qgnn_b9vv:@computed_region_26cr_cadq:@computed_region_ajp5_b2md:@computed_region_nqbw_i6c3:@computed_region_2dwj_jsy4:@computed_region_h4ep_8xdi:@computed_region_y6ts_4iup:@computed_region_jg9y_a9du:@computed_region_6pnf_4xz7geometry
02020-08-16T03:13:00.0002020-08-16T00:00:00.00003:132020Sunday2020-08-16T03:14:00.00095319604083953196200491669202290313.0...2.0926.0NaNNaNNaNNaNNaN2.0POINT (-122.39773 37.75483)
12020-08-16T03:38:00.0002020-08-16T00:00:00.00003:382020Sunday2020-08-16T04:56:00.00095326228100953262200491738202290404.0...3.0220.03.0NaNNaNNaNNaN2.0POINT (-122.42204 37.76654)
22020-08-16T13:40:00.0002020-08-16T00:00:00.00013:402020Sunday2020-08-16T13:56:00.00095336264020953362200492463202291631.0...1.0108.0NaNNaNNaNNaNNaN1.0POINT (-122.40371 37.78404)
32020-08-16T16:18:00.0002020-08-16T00:00:00.00016:182020Sunday2020-08-16T16:18:00.00095335012010953350200492792202292091.0...10.0735.0NaNNaNNaNNaNNaN1.0POINT (-122.50742 37.75100)
42020-08-12T22:00:00.0002020-08-12T00:00:00.00022:002020Wednesday2020-08-15T08:30:00.00095300674000953006200489880202280827.0...4.01139.0NaNNaNNaNNaNNaN2.0POINT (-122.43214 37.78050)
\n", "

5 rows × 37 columns

\n", "
" ], "text/plain": [ " incident_datetime incident_date incident_time \\\n", "0 2020-08-16T03:13:00.000 2020-08-16T00:00:00.000 03:13 \n", "1 2020-08-16T03:38:00.000 2020-08-16T00:00:00.000 03:38 \n", "2 2020-08-16T13:40:00.000 2020-08-16T00:00:00.000 13:40 \n", "3 2020-08-16T16:18:00.000 2020-08-16T00:00:00.000 16:18 \n", "4 2020-08-12T22:00:00.000 2020-08-12T00:00:00.000 22:00 \n", "\n", " incident_year incident_day_of_week report_datetime row_id \\\n", "0 2020 Sunday 2020-08-16T03:14:00.000 95319604083 \n", "1 2020 Sunday 2020-08-16T04:56:00.000 95326228100 \n", "2 2020 Sunday 2020-08-16T13:56:00.000 95336264020 \n", "3 2020 Sunday 2020-08-16T16:18:00.000 95335012010 \n", "4 2020 Wednesday 2020-08-15T08:30:00.000 95300674000 \n", "\n", " incident_id incident_number cad_number ... :@computed_region_qgnn_b9vv \\\n", "0 953196 200491669 202290313.0 ... 2.0 \n", "1 953262 200491738 202290404.0 ... 3.0 \n", "2 953362 200492463 202291631.0 ... 1.0 \n", "3 953350 200492792 202292091.0 ... 10.0 \n", "4 953006 200489880 202280827.0 ... 4.0 \n", "\n", " :@computed_region_26cr_cadq :@computed_region_ajp5_b2md \\\n", "0 9 26.0 \n", "1 2 20.0 \n", "2 10 8.0 \n", "3 7 35.0 \n", "4 11 39.0 \n", "\n", " :@computed_region_nqbw_i6c3 :@computed_region_2dwj_jsy4 \\\n", "0 NaN NaN \n", "1 3.0 NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "\n", " :@computed_region_h4ep_8xdi :@computed_region_y6ts_4iup \\\n", "0 NaN NaN \n", "1 NaN NaN \n", "2 NaN NaN \n", "3 NaN NaN \n", "4 NaN NaN \n", "\n", " :@computed_region_jg9y_a9du :@computed_region_6pnf_4xz7 \\\n", "0 NaN 2.0 \n", "1 NaN 2.0 \n", "2 NaN 1.0 \n", "3 NaN 1.0 \n", "4 NaN 2.0 \n", "\n", " geometry \n", "0 POINT (-122.39773 37.75483) \n", "1 POINT (-122.42204 37.76654) \n", "2 POINT (-122.40371 37.78404) \n", "3 POINT (-122.50742 37.75100) \n", "4 POINT (-122.43214 37.78050) \n", "\n", "[5 rows x 37 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pandas import read_csv\n", "from geopandas import GeoDataFrame, points_from_xy\n", "\n", "df = read_csv('https://libs.cartocdn.com/cartoframes/samples/sf_incidents.csv')\n", "\n", "gdf = GeoDataFrame(df, geometry=points_from_xy(df['longitude'], df['latitude']))\n", "gdf.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Compute geometry from WKT/WKB**" ] }, { "cell_type": "code", "execution_count": 4, "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", " \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", "
the_geomcartodb_idfield_1nameaddressrevenueid_storegeometry
00101000020E61000005EA27A6B607D52C01956F146E655...10Franklin Ave & Eastern Pkwy341 Eastern Pkwy,Brooklyn, NY 112381321040.772APOINT (-73.95901 40.67109)
10101000020E6100000B610E4A0847D52C0B532E197FA49...21607 Brighton Beach Ave607 Brighton Beach Avenue,Brooklyn, NY 112351268080.418BPOINT (-73.96122 40.57796)
20101000020E6100000E5B8533A587F52C05726FC523F4F...3265th St & 18th Ave6423 18th Avenue,Brooklyn, NY 112041248133.699CPOINT (-73.98976 40.61912)
30101000020E61000008BA6B393C18152C08D62B9A5D550...43Bay Ridge Pkwy & 3rd Ave7419 3rd Avenue,Brooklyn, NY 112091185702.676DPOINT (-74.02744 40.63152)
40101000020E6100000CEFC6A0E108052C080D4264EEE4B...54Caesar's Bay Shopping Center8973 Bay Parkway,Brooklyn, NY 112141148427.411EPOINT (-74.00098 40.59321)
\n", "
" ], "text/plain": [ " the_geom cartodb_id field_1 \\\n", "0 0101000020E61000005EA27A6B607D52C01956F146E655... 1 0 \n", "1 0101000020E6100000B610E4A0847D52C0B532E197FA49... 2 1 \n", "2 0101000020E6100000E5B8533A587F52C05726FC523F4F... 3 2 \n", "3 0101000020E61000008BA6B393C18152C08D62B9A5D550... 4 3 \n", "4 0101000020E6100000CEFC6A0E108052C080D4264EEE4B... 5 4 \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", "3 Bay Ridge Pkwy & 3rd Ave 7419 3rd Avenue,Brooklyn, NY 11209 \n", "4 Caesar's Bay Shopping Center 8973 Bay Parkway,Brooklyn, NY 11214 \n", "\n", " revenue id_store geometry \n", "0 1321040.772 A POINT (-73.95901 40.67109) \n", "1 1268080.418 B POINT (-73.96122 40.57796) \n", "2 1248133.699 C POINT (-73.98976 40.61912) \n", "3 1185702.676 D POINT (-74.02744 40.63152) \n", "4 1148427.411 E POINT (-74.00098 40.59321) " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pandas import read_csv\n", "from geopandas import GeoDataFrame\n", "from cartoframes.utils import decode_geometry\n", "\n", "df = read_csv('https://libs.cartocdn.com/cartoframes/samples/starbucks_brooklyn_geocoded.csv')\n", "\n", "gdf = GeoDataFrame(df, geometry=decode_geometry(df['the_geom']))\n", "gdf.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read data from a CARTO table\n", "\n", "_Note: You'll need your [CARTO Account](https://carto.com/signup) credentials to perform this action._" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from cartoframes.auth import set_default_credentials\n", "\n", "set_default_credentials('cartoframes')" ] }, { "cell_type": "code", "execution_count": 6, "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", " \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
34POINT (-74.02744 40.63152)3Bay Ridge Pkwy & 3rd Ave7419 3rd Avenue,Brooklyn, NY 112091185702.676
45POINT (-74.00098 40.59321)4Caesar's Bay Shopping Center8973 Bay Parkway,Brooklyn, NY 112141148427.411
\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", "3 4 POINT (-74.02744 40.63152) 3 \n", "4 5 POINT (-74.00098 40.59321) 4 \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", "3 Bay Ridge Pkwy & 3rd Ave 7419 3rd Avenue,Brooklyn, NY 11209 \n", "4 Caesar's Bay Shopping Center 8973 Bay Parkway,Brooklyn, NY 11214 \n", "\n", " revenue \n", "0 1321040.772 \n", "1 1268080.418 \n", "2 1248133.699 \n", "3 1185702.676 \n", "4 1148427.411 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from cartoframes import read_carto\n", "\n", "gdf = read_carto('starbucks_brooklyn')\n", "gdf.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read data from a CARTO SQL Query\n", "\n", "_Note: You'll need your [CARTO Account](https://carto.com/signup) credentials to perform this action._" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "from cartoframes.auth import set_default_credentials\n", "\n", "set_default_credentials('cartoframes')" ] }, { "cell_type": "code", "execution_count": 8, "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": 8, "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": "markdown", "metadata": {}, "source": [ "### Upload data to CARTO\n", "\n", "_Note: You'll need your [CARTO Account](https://carto.com/signup) credentials to perform this action._" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "from cartoframes.auth import set_default_credentials\n", "\n", "set_default_credentials('creds.json')" ] }, { "cell_type": "code", "execution_count": 10, "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": 10, "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": 4 }