Skip to content

[Bug] pydeck breaks streamlit with pandas 3 #9986

@lukasmasuch

Description

@lukasmasuch

Description

I'm a maintainer of streamlit and we are working on supporting pandas 3. From our tests, it looks like there might be a compatibility issue with the json serializer:

.venv/lib/python3.13/site-packages/pydeck/bindings/json_tools.py:74: TypeError

def default_serialize(o, remap_function=lower_camel_case_keys):
    """Default method for rendering JSON from a dictionary"""
    if issubclass(type(o), PydeckType):
        return repr(o)
>   attrs = vars(o)
            ^^^^^^^
E   TypeError: vars() argument must have __dict__ attribute

The default_serialize function calls vars(o) on a weakref to a pandas DataFrame. In pandas 3.x, vars() fails because DataFrames no longer have a __dict__ attribute that vars() can access.

Flavors

  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CARTO
  • ArcGIS

Expected Behavior

Works without an exception.

Steps to Reproduce

The error will be caused with Pandas 3, if a DataFrame is passed as data to a Layer, and .to_json() gets called on the pydeck object.

Environment

  • Framework version: pydeck@0.9.1
  • Browser: Chrome
  • OS: MacOS

Logs

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions