Skip to content

plotly.express.bar does not work with pandas uint32 dtype when passing in a list of values for y #4344

Description

@coradek

plotly.express.bar does not display properly when using pandas "uint32" dtype and passing a list for y


temp = pd.DataFrame({"my_category":list("ABCD"),"feature_1":[10, 20, 40, 30],"feature_2":[60, 40, 50, 20]})

for col in temp.columns:
    if temp[col].dtype == "int64":
        temp[col] = temp[col].astype("uint32")

px.bar(
    data_frame = temp,
    x = "my_category",
    y = ["feature_1","feature_2"],
)

Screenshot 2023-08-29 at 11 58 07 AM

using the "int64" dtype or plotting a single y works correctly

Screenshot 2023-08-29 at 11 58 31 AM Screenshot 2023-08-29 at 11 59 01 AM

This last image is the expected behavior

plotly.version = 5.16.1
pandas.version = 2.0.2

Activity

  1. self-assigned this
    on Jul 11, 2024
  2. removed their assignment
    on Aug 2, 2024
  3. emilykl commented on Sep 1, 2026

    @emilykl
    Contributor

    Looks like this is the same root cause as #4291, with the same potential fix.

    Pasting the relevant portion of my comment from #4291:

    Looks like the bug traces to the _is_continuous() function in plotly/express/_core.py, which evaluates to False in the case of Rain_count, causing Plotly Express to decide that Rain_count is the categorical array and should be treated as the bar labels.

    It seems the root cause is that dtype.kind for the Rain_count column is u, which is not one of "ifc".

    Plausibly we should just change "in "ifc" to in "ifcu" — @MarcoGorelli do you see any issue with that? Looks like that does resolve the issue.

    Numpy dtype.kind values: https://numpy.org/doc/stable/reference/generated/numpy.dtype.kind.html

    It looks like this bug is also caused by uint32 columns not being treated as numeric.

  4. added a commit that references this issue on Sep 15, 2026
    f954c9f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething broken

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions