Skip to content

FutureWarning when using "color" argument in plotly express with pandas 2.2.0 #4500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BlastoiseBlue opened this issue Jan 31, 2024 · 4 comments
Labels
sev-1 blocker

Comments

@BlastoiseBlue
Copy link

Pandas looks like it will be changing the semantics of the get_group() method in a future version, specifically for groupings created using a length-1 list-like. The current behavior of it accepting a single value in get_group() is deprecated, and will require using a tuple in the future. (This only applies to groupings created with a length-1 list (groupby(["a"]),) groupings created with a single value (groupby("a")) are unaffected.)

import plotly.express as px

px.scatter(x=[1, 2, 3], y=[10, 20, 30], color=["a", "b", "a"])

/opt/conda/lib/python3.11/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.
@vindevoy
Copy link

Is there a way to surpress this warning ?

@fzyzcjy
Copy link

fzyzcjy commented Apr 4, 2024

I am seeing the same thing, is there any fixes? Thanks!

@BlastoiseBlue
Copy link
Author

The behavior that causes the warning is fixed in v5.19.0, but if you're using an older version, then I believe this should silence the warning:

import warnings

warnings.filterwarnings(
    action="ignore",
    message=r"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\.",
    category=FutureWarning,
    module=r"plotly\.express\._core",
)

@Coding-with-Adam
Copy link
Contributor

Thank you @BlastoiseBlue for the solution to silence the warning for previous versions.

For now, since Plotly v5.19.0 fixes the issue, I'm going to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sev-1 blocker
Projects
None yet
Development

No branches or pull requests

4 participants