I’m trying to create a sunburst plot where different rows have different lengths, and get the error message 'dtype: object, ‘is not a leaf.’ I have read this ‘Note that the parents of None entries must be a leaf, i.e. it cannot have other children than None (otherwise a ValueError is raised).’ on the plotly pages https://plotly.com/python/sunburst-charts/#rectangular-data-with-missing-values but don’t fully understand that.
I have a bigger dataset, but the same thing happens with this one:
testdf = pd.DataFrame( [['Max',10,'M','a', 'x',None], ['Ma',5, 'M', 'a', None,None], ['Johan',6, 'J','o','h','a']], index=[1, 2, 3], columns=['First_Name','Count','a', 'b', 'c','d']) testdf fig=px.sunburst(testdf,path=['a','b','c','d'],values='Count') fig.show()
The ValueError is this:
ValueError: (‘Non-leaves rows are not permitted in the dataframe \n’, a M b a c
Name: 1, dtype: object, ‘is not a leaf.’)
So I think it’s caused by the fact that the letter a is not a leaf since the x of the first row is also attached to it, but I would like to have the sunburst stop at the letter a for the second row, and at the letter x for the first row. Any help is greatly appreciated!