question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change Layer API - Dataframe / Common Source

See original GitHub issue

Related with https://github.com/CartoDB/cartoframes/issues/615

Context

This issue focuses on continuing the previous issue about the Layer API (https://github.com/CartoDB/cartoframes/issues/615)

The first part of changing the Layer API was to use a single Layer class instead of having different Layer types, and create different sources that are equivalent to CARTO VL sources for consistency.

In this second step, we aim to use the Dataframe class to have the possibility of generating sources in the notebook and pass it to the Layer.

From this comment by @oleurud:

The user wants to make things over the data (using Pandas) and then render a map with the data. To do this, we have 2 options:

  • OPTION 1: the user makes things over the data (pandas or other ways), then upload the data to CARTO and finally use the VL way to render the map. To do this, if I am not wrong, we don’t have to integrate anything between backend and frontend.
  • OPTION 2: the user makes things over the data (pandas) and then the user has a way to send the pandas.DataFrame to VL. To do this, we have to integrate backend and frontend (find a way to send a pandas.DataFrames to VL). The yesterday proposal was talking about this case, because I think having a full local way to render a map is powerful. I want to talk about it with @javitonino & @alrocar. But of course, any feedback is welcome.

The first one is already implemented by frontend team. So the objective here is to find the best way to make possible the second one (if it makes sense)

Other questions / ToDo:

  • Use a Layer as a stand-alone map a la layer.map() (from this comment)
  • Discuss: Should we sort the layers?

Update

We have finally decided to simplify the API. New examples are contained in /examples/debug/API. This is an example of the usage:

from cartoframes import Context, set_default_context
from cartoframes.vis import Map, Layer

context = Context(
    base_url='https://cartovl.carto.com/', 
    api_key='default_public'
)
set_default_context(context)

# Table name
Map(Layer('populated_places', 'color: blue'))

# SQL query
Map(Layer('SELECT * FROM populated_places LIMIT 10'))

# GeoJSON (object, features, feature, geometry, filename, GDF)
Map(Layer(geojson))

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Jesus89commented, May 13, 2019

I have implemented here the idea of the connection between Source and Dataset, and also added some examples with the approach for the API: https://github.com/CartoDB/cartoframes/pull/662.

1reaction
elenatorrocommented, Apr 30, 2019

I included a PoC encoding the GeoJSON in base64 in the current PR: https://github.com/CartoDB/cartoframes/pull/626/commits/dc83d9297074288860cafab30b519dac055e9ecb

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introduction to the Spatially Enabled DataFrame
The Spatially Enabled DataFrame inserts a custom namespace called spatial into the popular Pandas DataFrame structure to give it spatial abilities. This allows ......
Read more >
Data Engineering with Spatially Enabled DataFrames and ...
Pandas is a data analysis and data engineering library that is very popular in the scientific Python ecosystem. The ArcGIS API for Python ......
Read more >
pandas.DataFrame.stack — pandas 1.5.2 documentation
Return a reshaped DataFrame or Series having a multi-level index with one or more new inner-most levels compared to the current DataFrame. The...
Read more >
Pandas API on Upcoming Apache Spark™ 3.2 - Databricks
A few years ago, we launched Koalas, an open source project that implements the pandas DataFrame API on top of Spark, which became...
Read more >
Load a pandas DataFrame | TensorFlow Core
Typically, Keras models and layers expect a single input tensor, but these classes can accept and return nested structures of dictionaries, tuples and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found