This example illustrates how to read data from a CARTO table using a SQL Query.
Use this when you need to see or modify the data locally. If you only need to visualize the data, just use the query directly in the Layer:
Layer('SELECT * FROM dataset_name')
Note: You'll need CARTO Account credentials to reproduce this example.
from cartoframes.auth import set_default_credentials
set_default_credentials('cartoframes')
from cartoframes import read_carto
gdf = read_carto("SELECT * FROM starbucks_brooklyn WHERE revenue > 1200000")
gdf.head()
cartodb_id | the_geom | field_1 | name | address | revenue | |
---|---|---|---|---|---|---|
0 | 1 | POINT (-73.95901 40.67109) | 0 | Franklin Ave & Eastern Pkwy | 341 Eastern Pkwy,Brooklyn, NY 11238 | 1321040.772 |
1 | 2 | POINT (-73.96122 40.57796) | 1 | 607 Brighton Beach Ave | 607 Brighton Beach Avenue,Brooklyn, NY 11235 | 1268080.418 |
2 | 3 | POINT (-73.98976 40.61912) | 2 | 65th St & 18th Ave | 6423 18th Avenue,Brooklyn, NY 11204 | 1248133.699 |
from cartoframes.viz import Layer
Layer(gdf)