CARTO + Python

CARTO + Python

Overview

Python has become one of the most commonly used languages for data science. In order to provide data scientists the ability to interact with CARTO from their most common working interfaces, CARTO provides a set of Python packages to allow data scientists to work with our platform from within Python notebooks; to run analysis, build data pipelines, machine learning processes and other data science workflows. These packages allow users to work with geospatial data in a fully cloud native way without having to leave their Python environment, and taking advantage of all the potential that Analytics Toolbox provides to execute advanced spatial analytics in Spatial SQL natively within the leading cloud data warehouse platforms.



CARTO currently provides two open source Python libraries to interact with the platform:


  • carto-auth: to provide the user the possibility to authenticate with the CARTO account from a Python notebook, and to get access to the data objects (i.e. tables, tilesets, functions) that are available via the different connections to cloud data warehouses that have been set up in that CARTO account. This also includes access to the resources available via the CARTO Data Warehouse connection, with access to the functions from the Analytics Toolbox (based on its implementation for Google BigQuery). This package includes:
    • CARTO Authentication via OAuth and M2M tokens.
    • Obtaining the access token of the session.
    • Creating a CARTO DW client to operate with it.

  • pydeck-carto: to be able to visualize the tables and tilesets available in your cloud data warehouse as map layers within your data science workflows in Python notebooks using the CartoLayer for pydeck:
    • It provides access to the data objects available in the connections created in the CARTO platform.
    • It supports color styling functions: bins, category, continuous.
    • It supports visualizing tilesets and our dynamic tiling implementation for medium size datasets.


Spatial Data Science workflows in Python often rely on the usage of geopandas in Jupyter notebooks as the de facto standards. Now, users can also integrate CARTO features into these workflows with this set of Python packages, which will save data scientists time and energy spent in switching contexts and working environments. To understand the fundamentals of our packages, in this documentation you will find guides in Working with data section.