I'm working with data that shows order flow across multiple rows, with each row being an independent stop/station. Sample data looks like this:
Firm event_type id previous_id
0 A send 111
1 B receive and send 222 111
2 C receive and execute 333 222
3 D receive and execute 444 222
4 E receive and cancel 123 100
The link here is decided by the two fields "id" and "previous_id". For instance, in the sample data, the previous_id
of Firm B is the same as the id
of Firm A, 111. Therefore order flows from Firm A to Firm B.
And for Firm E, since its previous_id
doesn't match the id
of any row, I intend it to be a standalone part in the flow.
Therefore what I want to achieve based on the sample data is something like this:
(Color is just for illustration purposes, not a must have).
I have been trying to work upon answer from @Dinari in this related question but couldn't get it to work. I would like the label of the networkx directed chart to be a column other than the columns with shared values.
Thanks.
draw_networkx
function doesn't show direction between nodes, which is quite important for my case. Is there anyway to modify your code to achieve that? Thanks. – Monostylous