title: Read data from a pandas DataFrame and create a tree using anytree in python
body: <p>Is there a way to read data from a pandas DataFrame and construct a tree using anytree?</p>
  <pre><code>Parent Child
  A      A1
  A      A2
  A2     A21
  </code></pre>
  <p>I can do it with static values as follows. However, I want to automate this by reading the data from a pandas DataFrame with anytree.</p>
  <pre><code>&gt;&gt;&gt; from anytree import Node, RenderTree
  &gt;&gt;&gt; A = Node(&quot;A&quot;)
  &gt;&gt;&gt; A1 = Node(&quot;A1&quot;, parent=A)
  &gt;&gt;&gt; A2 = Node(&quot;A2&quot;, parent=A)
  &gt;&gt;&gt; A21 = Node(&quot;A21&quot;, parent=A2)
  </code></pre>
  <p>Output is</p>
  <pre><code>A
  ├── A1
  └── A2
      └── A21
  </code></pre>
  <p>This question AND especially the ANSWER has been adopted, copied really, from:</p>
  <p><a href="https://stackoverflow.com/questions/51902250/read-data-from-a-file-and-create-a-tree-using-anytree-in-python">Read data from a file and create a tree using anytree in python</a></p>
  <p>Many thanks to @Fabien N</p>