这里解释一下:https://community.plotly.com/t/sunburst-chart-cant-handle-none-values/35383 https://community.plotly.com/t/sunburst-chart-cant-handle-none-values/35383.
基本上,如果你有一个None
价值,它的父母必须是独一无二的。在您的示例中,第一行有效。第二个不是因为["M", "a", None, None]
与以下对象共享同一个父对象["M", "a", "x", None]
.
事实上,如果你运行下面的命令,它就会起作用。
testdf = pd.DataFrame([
['Max', 10, 'M', 'a', 'x', None],
['Ma', 5, 'M', 'a', 'd', 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')