Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tree using CSV
#1
I have a CSV dataset having columns like ID,Name,ParentId and I want to visualise it in Tree format Please Help anybody
id,Name,ParentId
ACAD0100,Academics,
ACAD0101,Science,ACAD0100
ACAD0201,Maths,ACAD0100
ACAD0301,Social Science,ACAD0100
ACAD0102,Biology ,ACAD0101
ACAD0103,Biotechnology,ACAD0101
ACAD0105,Health & Wellness,ACAD0101
ACAD0202, Algebra,ACAD0201
ACAD0203,Calculus,ACAD0201
ACAD0204,Geometry,ACAD0201
ACAD0302, Anthropology,ACAD0301
ACAD0303, Psychology,ACAD0301
This is just small part of dataset.
Reply
#2
What does it mean to visualize it in tree format?
Reply
#3
you mean a table view ?

PyQt5 CSV

looks like this

[Image: csv_test.png]
Reply
#4
May his name is a hint pandeyrishabh Wink
Quote:visualise it in Tree format
This is as mention unclear.
import pandas as pd
from io import StringIO
 
data = StringIO('''\
id,Name,ParentId
ACAD0100,Academics,
ACAD0101,Science,ACAD0100
ACAD0201,Maths,ACAD0100
ACAD0301,Social Science,ACAD0100
ACAD0102,Biology ,ACAD0101
ACAD0103,Biotechnology,ACAD0101
ACAD0105,Health & Wellness,ACAD0101
ACAD0202, Algebra,ACAD0201
ACAD0203,Calculus,ACAD0201
ACAD0204,Geometry,ACAD0201
ACAD0302, Anthropology,ACAD0301
ACAD0303, Psychology,ACAD0301''')
 
df = pd.read_csv(data, sep=",")
df
[Image: VvVMTt.png]
Reply
#5
I want to do something like this.
https://drive.google.com/file/d/1itMYLEU...sp=sharing

please check the image file
Reply
#6
(Aug-03-2018, 11:51 AM)pandeyrishabh Wrote: I want to do something like this.
How will the computer know that Anthropology is not a part of Maths ?

EDIT: sorry, I didn't see the parent ID
Reply
#7
Same thing I am also searching as in data ParentId and Id is defined. I have to just visualise like Physics, chemistry maths comes under science, in the same manner, I want something to work upon dataset.
If you have some better way please suggest.
Reply
#8
I would recommend using module asciitree to print a simple tree in the terminal, or pydot or pydotplus to create an image file.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020