plotly library has some nice sankey diagrams https://plotly.com/python/sankey-diagram/
but the data requires you to pass indexes of the source/target pairs.
link = dict(
source = [0, 1, 0, 2, 3, 3], # indices correspond to labels, eg A1, A2, A1, B1, ...
target = [2, 3, 3, 4, 4, 5],
I was wondering if there's an API to simply pass a named list of these pairs?
links = [
{'source': 'start', 'target': 'A', 'value': 2},
{'source': 'A', 'target': 'B', 'value': 2},
...
]
this is more inline with how bokeh/holoviews expects data (but that sankey doesn't work with self-loops)
and also this pysankey widget
so i can closer map to my dataframe without processing everything?
or, is there a nice pythonic way to convert this in a one liner :D