'Sankey/ Alluvial plots in Python

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)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source