Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the Graphviz library and in pandas and jupyternotebook this is the dataset values this is the output required however this is my code but

Using the Graphviz library and in pandas and jupyternotebook this is the dataset values 

this is the output required


 

however this is my code but i am getting error and need help with it 

code below

import pandas as pd
from graphviz import Digraph

 

# Load the data
#df = pd.read_csv("dataframe.csv")
df = pd.read_csv('dataframe.csv', index_col = "ID") # df is "data frame"

 

#replace all occurances of "Not A Number" (NaN) with "Nothing" (None)
df.replace({float("nan"): None}, inplace=True) 

 

# Create the graph
graph = Digraph(format='jpg')

 

# Create Nodes for all entries in dataframe
nodeMap = {None:None}

 

#process your data frame from the bottom up
print("Creating Nodes for Tree")
for index in reversed(df.index.values):
   #print("Creating Node for: ",index)
   nodeMap[index] = Node(df.loc[index]["Label"],nodeMap[df.loc[index]["Left Child"]],nodeMap[df.loc[index]["Right Child"]]) - NameError: name 'Node' is not defined

 


ID root Label Right Child Left Child Is it a person not a thing? person thing Real not fictional? washington frodo person washington George Washington Frodo Baggins Bigger than a breadbox? truck A truck A cell phone frodo thing truck cellphone cellphone

Step by Step Solution

3.55 Rating (155 Votes )

There are 3 Steps involved in it

Step: 1

The suggested code is as follows In this code several modifications are made and they incl... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Human Resource Management

Authors: Lloyd Byars, Leslie Rue

10th Edition

73530557, 978-0071220668, 71220666, 978-0073530550

More Books

Students also viewed these Programming questions

Question

How is an applicant flow record used?

Answered: 1 week ago

Question

How often do you think performance appraisals should be conducted?

Answered: 1 week ago

Question

7. What is the relationship between birth order and homosexuality?

Answered: 1 week ago

Question

5. What does the enzyme 5a-reductase 2 do?

Answered: 1 week ago