I have a list of clicks on a website for a set of users. I'm trying to create a flow of clicks through the website. With the code below I get the following result. I'd like to have the end of the first bundle be joined with the end of the second bundle, otherwise it just looks weird.
import floweaver as fw
import pandas as pd
df = pd.DataFrame(
data={'event_no': [1, 1, 1, 2, 2, 2, 2, 2, 3, 3],
'source': ['Home', 'Home', 'Home', 'Products', 'Products', 'Products', 'About', 'About', 'Product1', 'Product1'],
'target': ['About', 'Products', 'Other', 'Product1', 'Product2', 'Product3', 'Products', 'Other', 'Buy', 'Buy'],
'value': [100, 300, 150, 150, 75, 50, 50, 10, 20, 10]}
)
size = {'width': 600, 'height': 600}
nodes = {
'Event1': fw.ProcessGroup(df.loc[df['event_no'] == 1, 'source'].unique().tolist()),
'Event2': fw.ProcessGroup(df.loc[df['event_no'] == 2, 'source'].unique().tolist()),
'Event3': fw.ProcessGroup(df.loc[df['event_no'] == 3, 'source'].unique().tolist())
}
ordering = [
['Event1'],
['Event2'],
['Event3']
]
bundles = [
fw.Bundle('Event1', 'Event2'),
fw.Bundle('Event2', 'Event3')
]
nodes['Event1'].partition = fw.Partition.Simple('source', df.loc[df['event_no'] == 1, 'source'].unique())
nodes['Event2'].partition = fw.Partition.Simple('source', df.loc[df['event_no'] == 2, 'source'].unique())
nodes['Event3'].partition = fw.Partition.Simple('source', df.loc[df['event_no'] == 3, 'source'].unique())
sdd = fw.SankeyDefinition(nodes, bundles, ordering)
fw.weave(sdd, df).to_widget(**size)
I tried using a waypoint which works when I have only one event in between, but for some reason it won't work when I have 4+ event_no and use [2, 3, ...] as waypoints.
Any ideas how to make this work?