#!/usr/bin/env python # coding: utf-8 # ## Enrichment Subscription Workflow # # This example illustrates how to subscribe and enrich with CARTO's Data Observatory. # # _Note: You'll need [CARTO Account](https://carto.com/signup) credentials to reproduce this example._ # In[1]: from cartoframes.auth import set_default_credentials set_default_credentials('creds.json') # In[2]: dataset_name = 'carto-do.ags.demographics_retailpotential_usa_blockgroup_2015_yearly_2019' # In[3]: from cartoframes.data.observatory import Catalog, Dataset, Geography dataset = Dataset.get(dataset_name) # In[4]: dataset.subscribe() # NOTE: After the subscription request of the premium dataset, we will contact you to **perform and complete the premium subscription**. When the process is completed, you will be able to access your premium dataset directly from CARTOframes or from the Dashboard in your CARTO account. # In[5]: Catalog().subscriptions() # In[6]: dataset.variables # In[7]: from cartoframes.data.observatory import Variable variable = Variable.get('MLTCY44411_acc8382c') variable # In[8]: from geopandas import read_file census_track = 'http://libs.cartocdn.com/cartoframes/files/census_track.geojson' census_track_gdf = read_file(census_track) census_track_gdf.head(3) # In[9]: from cartoframes.data.observatory import Enrichment enrichment = Enrichment() enriched_dataset_gdf = enrichment.enrich_polygons( census_track_gdf, variables=['MLTCY44411_acc8382c'] ) # In[10]: enriched_dataset_gdf.head(3) # In[11]: from cartoframes.viz import Layer, color_continuous_style Layer(enriched_dataset_gdf, color_continuous_style('MLTCY44411'))