Python Forum
Python Anytree - Is not of type 'NodeMixin' error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Anytree - Is not of type 'NodeMixin' error
#1
I am trying to build a Hierarchy from the below csv data:

Child,Parent,IsActive
11074165,11018432,NO
11094122,11033371,NO
11020499,11018277,NO
11018432,11020499,NO

Below is the code snippet

nodes = {}
with open("SampleHierarchy.csv", "r") as f:
    csv_reader = csv.DictReader(f)
    for row in csv_reader:
        #print(row['Code'], row['Parent'],row['IsActive'])
        childItem=row['Code']
        parentItem=row['Parent']
        nodes[childItem] = Node(childItem, parent=parentItem)
But getting the Error:

Error:
*Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile execfile(filename, namespace) File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "CounterpartyHierarchyTree.py", line 37, in <module> Node(childItem, parent=parentItem) File "C:\ProgramData\Anaconda3\lib\site-packages\anytree\node\node.py", line 77, in __init__ self.parent = parent File "C:\ProgramData\Anaconda3\lib\site-packages\anytree\node\nodemixin.py", line 127, in parent raise TreeError(msg) anytree.node.exceptions.TreeError: Parent node '11018432' is not of type 'NodeMixin'.*
Larz60+ write May-05-2022, 10:36 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use BBCode tags on future posts.
Reply


Messages In This Thread
Python Anytree - Is not of type 'NodeMixin' error - by georgebijum - May-05-2022, 09:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wrong type error rowan_bradley 6 1,311 Aug-07-2023, 10:44 AM
Last Post: rowan_bradley
  Type Error: Unsupported Operand jhancock 2 1,283 Jul-22-2023, 11:33 PM
Last Post: jhancock
  Incorrect Type Error milkycow 4 2,951 Jun-25-2021, 06:04 AM
Last Post: milkycow
Star Type Error: 'in' object is not callable nman52 3 3,453 May-01-2021, 11:03 PM
Last Post: nman52
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,118 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  Type Error in Python MarcusB 3 2,617 Mar-30-2021, 06:34 PM
Last Post: buran
  unsupported operand type(s) for /: 'str' and 'int' Error for boxplot soft 1 3,096 Feb-09-2021, 05:40 PM
Last Post: soft
  Type Error or Value Error? spalisetty06 3 2,439 Jul-21-2020, 04:56 AM
Last Post: deanhystad
  anytree implicit node? gw1500se 0 1,729 Jun-07-2020, 08:42 PM
Last Post: gw1500se
  Modifying anytree Nodes gw1500se 1 2,691 Jun-05-2020, 03:44 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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