I want to create a mindmap of money that I have sent and received using a CSV file with columns: from, to, money in, and money out.
I want to create a graph that shows money either moving in or out of each account, with the account I want to choose in the center.
I can't find a python library that does this. Is there a library that would let me do this? Or is that even possible using Python?
from graphviz import Digraph
import pandas as pd
import numpy as np
G = Digraph(format='jpeg')
G.attr(rankdir='LR', size='8,5')
G.attr('node', shape='circle')
df = pd.read_csv('so.csv')
# add the vertices
[G.node(str(x)) for x in np.unique(df[['From', 'To']].values.flatten())]
# add the edges
[G.edge(str(x[1][0]), str(x[1][1]), label=str(x[1][2])) for x in df.iterrows()]
G.render('sg', view=True)
Where the content of so.csv
is:
From,To,Amount
Account1,Account2,20
Account1,Account3,50
Account3,Account1,60
You will have: