Skip to content

remove bug in sunburst / treemap when passing a column named "parent" #2639

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
wants to merge 14 commits into from

Conversation

emmanuelle
Copy link
Contributor

@emmanuelle emmanuelle commented Jul 14, 2020

Closes #2607

[x] check what happens when 'parent' is passed for a column not in the path (color, hover, etc.)
[x] add tests

@emmanuelle
Copy link
Contributor Author

So when parent or id is passed as part of the path it's possible to handle this situation gracefully since the names in the path are not present in the transformed dataframe. 3697d41 takes care of replacing such names. However, what should we do in a case like below

import plotly.express as px
import pandas as pd
vendors = ["A", "B", "C", "D", None, "E", "F", "G", "H", None]
sectors = ["Tech", "Tech", "Finance", "Finance", "Other",
           "Tech", "Tech", "Finance", "Finance", "Other"]
regions = ["North", "North", "North", "North", "North",
           "South", "South", "South", "South", "South"]
sales = [1, 3, 2, 4, 1, 2, 2, 1, 4, 1]
df = pd.DataFrame(
    dict(parent=vendors, sectors=sectors, regions=regions) 
)

fig = px.sunburst(df, path=['regions', 'sectors'], color='parent')
fig.show()

The problem is that the column names passed in color, hover_data etc. are displayed in the hover_data. Should we give another arbitrary name like parent_col, or should we raise an error, saying that parent, id and label are reserved names and that one should use labels to change the name?

@nicolaskruchten nicolaskruchten added this to the 4.9.0 milestone Jul 14, 2020
@emmanuelle emmanuelle changed the title [WIP] remove bug in sunburst / treemap when passing a column named "parent" remove bug in sunburst / treemap when passing a column named "parent" Jul 15, 2020
@emmanuelle emmanuelle mentioned this pull request Jul 15, 2020
@nicolaskruchten nicolaskruchten modified the milestones: 4.9.0, 4.10 Jul 15, 2020
@emmanuelle emmanuelle closed this Jul 30, 2020
@archmoj archmoj deleted the sunburst_parent branch November 23, 2021 23:34
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.

cannot use column name "parent" for the dataframe passed to sunburst graph
2 participants