Giter Club home page Giter Club logo

pandas-erd's Introduction

Create ERD diagram from pandas dataframes

  • create an ERD object and add tables and connections between tables
  • save the generated dot code to an output.txt file containing
  • copy-paste the output.txt into a graphviz rendering tool like this one
  • the output image at the bottom is generated by using the above link

Installation via pip:

pip install pandaserd

Example use:

import pandas as pd
from pandaserd import ERD

df1 = pd.DataFrame(data=[[123, 32, '1 Ottawa Street'], [123, 80, '14 Canada Road']])
df1.columns = ['PERSON', 'AGE', 'ADDRESS']
df2 = pd.DataFrame(data=[[6342, 124123124124, '1992-01-02', 21, 'K012V4'], [3124, 154823124124, '1984-02-02',42,'L4Y6S2']])
df2.columns = ['PERSON', 'CREDIT_CARD', 'DOB', 'PERSON_AGE', 'POSTAL_CODE']

erd = ERD()
t1 = erd.add_table(df1, 'PERSON', bg_color='pink')
t2 = erd.add_table(df2, 'CREDIT_CARD', bg_color='skyblue')
erd.create_rel('PERSON', 'CREDIT_CARD', on='PERSON', right_cardinality='*')
erd.create_rel('PERSON', 'CREDIT_CARD', left_on='AGE', right_on='PERSON_AGE', left_cardinality='+', right_cardinality='+')

erd.write_to_file('output.txt')

example image

Credits

Largely inspired by this fab repo!

  • dot documentation can be found here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.