Skip to content

FutureWarning in _core.py #4505

@ramedina86

Description

@ramedina86

Using plotly==5.18.0 and pandas==2.2.0.

I get the following FutureWarning

.venv/lib/python3.12/site-packages/plotly/express/_core.py:2065: FutureWarning: When grouping with a length-1 list-like, you will need to pass a length-1 tuple to get_group in a future version of pandas. Pass `(name,)` instead of `name` to silence this warning.
  sf: grouped.get_group(s if len(s) > 1 else s[0])

I can suppress the warning by fixing a line in get_groups_and_orders()

sf: grouped.get_group(s if len(s) > 1 else s[0])

to

sf: grouped.get_group(s if len(s) > 1 else (s[0], ))

In my case, this only happens when I include color, which seems to trigger the grouping by tuple:

This doesn't work: fig = px.bar(main_df, x='role', y='count', color='role')
This works: fig = px.bar(main_df, x='role', y='count')

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