visgl / visgl/deck.gl

pydeck: Layers fail on data columns names with hyphens or whitespace

Open
#5,308 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug pydeck
Dominant language
TypeScript
Stars
14.6k
Forks
2.3k
Avg merge
2d 9h
Merged PRs (30d)
42

Description

The code sample below fails because of lng-new, which the JS expression parser in @deck.gl/json treats as datum.lng - datum.new.

import pydeck as pdk
import pandas as pd

UK_ACCIDENTS_DATA = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv'
df = pd.read_csv(UK_ACCIDENTS_DATA)
df['lng-new'] = df['lng']
df.head()

layer = pdk.Layer(
    'HexagonLayer',
    UK_ACCIDENTS_DATA,
    get_position=['lng-new', 'lat'],
    auto_highlight=True,
    elevation_scale=50,
    pickable=True,
    elevation_range=[0, 3000],
    extruded=True,                 
    coverage=1)

# Set the viewport location
view_state = pdk.ViewState(
    longitude=-1.415,
    latitude=52.2323,
    zoom=6,
    min_zoom=5,
    max_zoom=15,
    pitch=40.5,
    bearing=-27.36)

# Combined all of it and render a viewport
r = pdk.Deck(layers=[layer], initial_view_state=view_state)
r.show()

It's possible that pydeck should sanitize column names in a data frame before passing them to @deck.gl/json or warn if a column name contains a JS arithmetic operator or whitespace. Alternately it could make sense to change this behavior within @deck.gl/json.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the sample with the lng-new column, then trace how pydeck passes layer accessors to the @deck.gl/json expression parser. Compare whether handling belongs in pydeck or @deck.gl/json; done should define and verify behavior for hyphens, whitespace, and other JavaScript operators.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python, typescript
Domain
data-visualization
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.