title: How to create tree structure from hierarchical data in Python?
body: <p>Hi I am a bit new to Python and am a bit confused how to proceed. I have a large dataset that contains both parent and child information. For example, if we have various items and their components, and their components also have other components or children, how do we create a type of tree structure? Here is an example of the data:
  <a href="https://i.stack.imgur.com/FkhAO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FkhAO.png" alt="enter image description here" /></a></p>
  <p>I was wondering how I can get it into a tree structure. So the output would be:</p>
  <p><a href="https://i.stack.imgur.com/hSzeq.png" rel="nofollow noreferrer">Tree structure for car</a></p>
  <p>and it will also return the one for airplane, similar to the one for car.</p>
  <p>I know that the common attribute for this would be based upon the parent number/child number. But, I am a bit confused on how to go about this in python.</p>