8000 Handle serializing dicts with ints and strings · Issue #3380 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content
Handle serializing dicts with ints and strings #3380
Closed
@chriddyp

Description

@chriddyp

The current to_json_plotly doesn't handle dicts with integers and strings as keys. This used to work before we set sort_keys=True.

This is relatively common in Dash.

Here is a MWE:

import pandas as pd
from plotly.io.json import to_json_plotly

df = pd.DataFrame({'a': [0], 1: [0]})
to_json_plotly(df.to_dict('records'))
TypeError: '<' not supported between instances of 'int' and 'str'

Here is the issue in the Python tracker: https://bugs.python.org/issue25457 re sort_keys=True

Originally reported in https://community.plotly.com/t/dash-2-0-0-migration-error/56478/7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0