Skip to content

pydeck_chart: Error (not a valid JSON) when data contains NaN #5799

@clo-vis

Description

@clo-vis

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

If the data used in pydeck contains NaN (even if it is not used), the application fails with
image

Reproducible Code Example

import math, pandas, pydeck, streamlit

streamlit.set_page_config(layout="wide")
data = pandas.DataFrame({"lng": [-109.037673], "lat": [36.994672], "weight": [math.nan]})
layer = pydeck.Layer("ScatterplotLayer", data=data, get_position=["lng", "lat"], radius_min_pixels=4)
deck = pydeck.Deck(layers=[layer], map_style=pydeck.map_styles.CARTO_LIGHT, tooltip={"text": "weight: {weight}"})
deck.to_html("test.html")
streamlit.pydeck_chart(deck, use_container_width=True)

Steps To Reproduce

Run the code as usual.

Expected Behavior

No error, as in the file test.html generated

Current Behavior

SyntaxError:
Unexpected token 'N', ...""weight": NaN "... is not valid JSON

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: Streamlit v1.15.1
  • Python version: 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
  • Operating System: Windows 10.0.19045.2251
  • Browser: Chome, Opera, Edge, Firefox
  • Virtual environment: poetry

Additional Information

No response

Are you willing to submit a PR?

  • Yes, I am willing to submit a PR!

Metadata

Metadata

Assignees

Labels

feature:st.pydeck_chartRelated to the `st.pydeck_chart` elementpriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions