Repository navigation
Conversation
Missing values in nullable pandas dtypes are pd.NA, and the group sort and the animation frame sort compared them with == via list.index and in, which raised. Look the positions up in a dict instead. Output for object, float and polars columns is unchanged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Closes #5895
Description of change
Plotly Express raised
TypeError: boolean value of NA is ambiguouswhen a column with a nullable pandas dtype (string,boolean,Int64,Float64, pyarrow-backed) had missing values and was used forcolor,symbol,line_dash,line_group,facet_row,facet_col,animation_frameorpattern_shape. The missing value ispd.NA, and the group sort and the animation frame sort compared it with==throughlist.indexandin. They now look the position up in a dict.Demo
After the change the example returns two traces (
u: x=[1, 4],v: x=[3]). The row with the missing group is dropped. Figures for object, float and polars columns with missing values are the same as before (colors, facets, axis order).The implementation and tests were written with AI assistance.
Testing strategy
New tests cover five nullable dtypes with five grouping arguments,
animation_frame,pattern_shapeandfacet_row, and columns where every value is missing (pandas and polars). The nullable cases fail onmainand pass with the change.tests/test_optional/test_pxpasses.Additional information (optional)
The CHANGELOG entry uses
#NNNNfor the PR number.Guidelines