0

I am using pandas dataframe in Jupyter notebook and would be interested in generating a Sankey/Alluvial plot. Below is the dataset

import pandas as pd

data = {
'v1_r':[4, 2, 4, 1, 1, 4, 3, 4, 2, 1, 4, 3, 3, 1, 1, 4, 1, 3, 3, 3, 1, 3, 1, 4, 1, 3, 2, 4, 4, 1, 1, 3, 4, 4, 4, 3, 3, 1, 1, 1, 1, 3, 2, 3, 4, 2, 4, 4, 4, 3, 3, 3, 4, 3, 4, 1, 1, 3, 4, 1, 1, 4, 1, 1, 1, 1, 3, 1, 1, 1, 4, 1, 3, 3, 2, 4, 4, 3, 1, 3, 4, 1, 1, 1, 1, 4, 1, 4, 3, 3, 4, 3, 2, 2, 1, 4, 1, 4, 1, 1, 1, 1, 2, 1, 3, 4, 1, 1, 2, 4, 3, 1, 4, 2, 2, 1, 1, 2, 2, 3, 1, 4, 1, 1, 4, 2, 2, 4, 4, 4, 1, 1, 4, 2, 4, 4, 3, 2, 3, 4, 1, 4, 3, 4, 1, 4, 2, 3, 1, 1],
'v3_r':[4, 2, 4, 3, 1, 4, 2, 1, 2, 1, 2, 3, 3, 1, 1, 4, 4, 3, 3, 3, 1, 3, 1, 4, 1, 4, 2, 4, 4, 1, 2, 3, 4, 3, 2, 3, 4, 1, 1, 1, 1, 2, 2, 2, 4, 1, 4, 4, 2, 3, 3, 4, 4, 3, 3, 1, 1, 3, 4, 3, 3, 2, 2, 1, 1, 1, 2, 1, 1, 1, 4, 1, 3, 3, 1, 4, 4, 4, 1, 3, 4, 3, 1, 1, 1, 3, 3, 4, 3, 2, 4, 3, 2, 2, 2, 4, 1, 4, 1, 1, 1, 1, 2, 4, 3, 4, 1, 1, 2, 1, 3, 1, 4, 2, 2, 3, 1, 2, 2, 2, 1, 3, 1, 4, 4, 2, 2, 4, 4, 4, 4, 1, 4, 3, 4, 4, 1, 1, 3, 1, 1, 4, 2, 3, 1, 4, 2, 1, 1, 1]}

df = pd.DataFrame(data)
Stephen Okiya
  • 315
  • 1
  • 8
  • [Sankey Diagram in Python](https://plotly.com/python/sankey-diagram/) – Tobi208 Feb 25 '22 at 07:48
  • 1
    I don't see how this data relates to what you expect for a Sankey Diagram. need source, target and value. see also for a simple way to build a sankey https://stackoverflow.com/questions/69463804/plotly-sankey-graph-data-formatting/69464558#69464558 – Rob Raymond Feb 25 '22 at 08:07
  • The data is of survey responses (i.e. pre and post) and the idea is to try understand change over time. Hope this helps! – Stephen Okiya Feb 25 '22 at 08:41

0 Answers0