Skip to content

parallel_coordinates is incorrect when using color and non-sorted index #3576

Closed
@shane-kercheval

Description

@shane-kercheval

This is somewhat of a weird bug, but I don't think it would be that uncommon of a use-case.

First let's see it working as expected.

If you run:

df = pd.DataFrame({
        'A': [1, 2, 3, 4],
        'B': [1, 2, 3, 4],
        'C': [1, 2, 3, 4],
    },
    index=[0, 1, 2, 3]
    #index=[3, 2, 1, 0]
)
df

px.parallel_coordinates(df)

you'll see

Screen Shot 2022-01-30 at 11 43 31 AM

Then run:

px.parallel_coordinates(df, color='B')

and you'll see

Screen Shot 2022-01-30 at 11 43 58 AM

Everything looks good so far.

But then change the index of the DataFrame from index=[0, 1, 2, 3] to index=[3, 2, 1, 0]

df = pd.DataFrame({
        'A': [1, 2, 3, 4],
        'B': [1, 2, 3, 4],
        'C': [1, 2, 3, 4],
    },
    #index=[0, 1, 2, 3]
    index=[3, 2, 1, 0]
)
df

px.parallel_coordinates(df)

This will return exactly the same graph as before. But when you use the color param, you get this

px.parallel_coordinates(df, color='B')

Screen Shot 2022-01-30 at 11 45 58 AM

Which is incorrect. For example, instead of 1-1-1 (which is still a single row, despite the change in index), the line goes from 1-4-1.

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