Skip to content

Consider necessary columns from complex arguments when interchanging dataframes - #4324

Merged
alexcjohnson merged 5 commits into
plotly:masterfrom
guyrosin:fix-necessary-columns
Aug 15, 2023
Merged

Consider necessary columns from complex arguments when interchanging dataframes#4324
alexcjohnson merged 5 commits into
plotly:masterfrom
guyrosin:fix-necessary-columns

Conversation

@guyrosin

Copy link
Copy Markdown
Contributor

This PR fixes a regression from #4286, where only plain string arguments were considered as necessary columns when interchanging dataframes. This PR considers complex arguments as well (such as hover_data).

For example, running the code below resulted in ValueError: Value of 'hover_data_0' is not the name of a column in 'data_frame'. Expected one of ['petal_length', 'sepal_length'] but received: species

import numpy as np
import plotly.express as px
import polars as pl

df = px.data.iris()
px.scatter(
    pl.from_pandas(df),
    x="petal_length",
    y="sepal_length",
    hover_data=["species"],  # <-- this was unsupported
)
  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the codegen files and not generated files.
  • I have added tests (if submitting a new feature or correcting a bug) or
    modified existing tests.
  • For a new feature, I have added documentation examples in an existing or
    new tutorial notebook (please see the doc checklist as well).
  • I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
  • For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).

Comment thread packages/python/plotly/plotly/express/_core.py Outdated
Comment thread packages/python/plotly/plotly/express/_core.py Outdated
@guyrosin
guyrosin force-pushed the fix-necessary-columns branch from 9aa93e3 to e2a7cb4 Compare August 14, 2023 22:03
@alexcjohnson

Copy link
Copy Markdown
Collaborator

Thanks so much @guyrosin ! Would you add a changelog entry, in a new ## UNRELEASED section at the top? Then I think this is ready to go, and we'll try to get a patch out shortly.

@guyrosin

guyrosin commented Aug 15, 2023

Copy link
Copy Markdown
Contributor Author

Done. That's great to hear! Thanks @alexcjohnson for the feedback

@alexcjohnson alexcjohnson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💃 Very nice! Thanks again for identifying AND fixing this regression @guyrosin

@alexcjohnson
alexcjohnson merged commit 402c9b4 into plotly:master Aug 15, 2023
@guyrosin
guyrosin deleted the fix-necessary-columns branch August 23, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants