I want to write a function that returns a tree based on JSON data.
This is a pandas dataframe:
employee_id designation department name manager_emp_id
1 co-founder co-founder john 2
2 ceo co-founder rocky
3 cto tech alfred 2
4 sde3 tech bruce 3
5 sde1 tech tony 4
6 cmo marketing steve 2
7 sde1 tech bucky 3
This is an example of the tree I'm looking for:
ceo
/ | \
/ | \
cto cmo coo
| | \
| | \
sde3 sales operative executives
|
|
sde1
Output format:
Desired Output
{
employee_id : 2,
name : rocky,
reportees : [
{
employee_id : 3,
name : alfred,
reportees:[....]
}
]
}