Can't plot Sunburst in Chart Studio GO format

I can’t chart a Sunburst despite reformatting my data as instructed. This works via PATH and easily; I had to build a script to convert data to GO formatting. This data is now stripped and looks like other datasets that are working in the examples now.

My data is here …

Still the chart won’t render … the only thing missing in data are values for parents, but that should be unimportant I think…

Here is the code that turns the “path” spreadsheet into this go. Sunburst formatting … if its a help

import plotly.graph_objects as go
import pandas as pd


df = pd.read_csv(’…/CSV/Indicators50.csv’)
df = df[[“code”, “desc”, “score”, “topic”, “subtopic1”, “subtopic2”, “subtopic3”]].drop_duplicates()
#df.loc[df[‘parents’].isna(), ‘parents’] = ‘’

df[‘parents’] = df.topic.str.strip() + ’ - ’ + df.subtopic1.str.strip()
df[‘ids’] = df.parents + ’ - ’ + df.code.str.strip()
df[‘labels’] = df.code.str.strip()
#df[‘labels’] = df.desc.str.strip()

create the dedicated IDs rows

df_ids = df.sort_values(‘subtopic1’).drop_duplicates([‘subtopic1’], keep=‘last’)
#print(“Length of df_inds:”, len(df_ids))
for i in range(len(df_ids)):
df = df.append({‘ids’:df_ids.iloc[i,3] + ’ - ’ + df_ids.iloc[i,4], ‘parents’:df_ids.iloc[i,3], ‘labels’:df_ids.iloc[i,4], ‘score’:df_ids.iloc[i,2]}, ignore_index=True)

#create the dedicated Parents rows in dataframe
df_parents = df.topic.drop_duplicates().reset_index(drop=True)

don’t count the newly added Parents records

#df_parents = df_parents.dropna((subset=[‘code’]) )
df_parents = df_parents.dropna()
for i in df_parents:
df = df.append({‘parents’:"", ‘ids’:i, ‘labels’:i}, ignore_index=True)
#print(“Shape of df_parents:”, df_parents.shape)
#print(“Shape of df:”, df.shape)


fig = go.Figure()


grid= dict(columns=2, rows=1),
margin = dict(t=0, l=0, r=0, b=0)

Hi @etilley, I took a look at the Javascript console in Chart Studio (accessed through developer tools, it can be a good way to debug when something is going wrong) for your viz, and it said “multiple implied roots, cannot build sunburst hierarchy”. I solved the problem by adding None (anything else would do I think) as the parent of your top-level sectors, see the attached screenshot.

Thanks - I cleaned up the script some more and got it working. The clean up resorted the parents to the top of the chart.

The script doesn’t work on a python Jupyter notebook for some reason, but it’s working as a python program just as well as the express “path” equivalent…

Express is a much better Sunburst implementation; much simpler to implement large datasets - with score values as well. This wheel has 1500 lines and another category still to add … without that path tool its brutal to load.

I went to this trouble to get the onclick() to work - to launch an html url on clicking a leaf. Do you have any advice on making that work?

Thanks in advance @Emmanuelle