0

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.

Exmaples from the CSV file

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.

What I am envisioning

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?

  • It's possible to do in python but there is no dedicated library for mind-map as far as I know. You have to cook up a way to make the graph using `matplotlib` library. – Abdur Rakib Jan 10 '22 at 06:39
  • 1
    https://github.com/MartinPacker/filterCSV – Aydin K. Jan 10 '22 at 06:45
  • 1
    you could create a graph structure and visualize it. check out https://towardsdatascience.com/visualizing-networks-in-python-d70f4cbeb259 – Tibebes. M Jan 10 '22 at 06:48

1 Answers1

2
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:

enter image description here

Mehdi Khademloo
  • 2,754
  • 2
  • 20
  • 40