Skip to content

Merging two identical trees with different attributes #331

Answered by kayjan
chhei asked this question in Questions
Discussion options

You must be logged in to vote

Hello, thanks for the suggestion! In this scenario it will be more straightforward to convert the trees to dataframe, perform dataframe operation of merging, then converting it back to a tree because there is no 'shifting' or 'copying' involved if it is just to combine the attributes.

Something like this -

import pandas as pd
from bigtree import dict_to_tree, tree_to_dataframe, dataframe_to_tree

# Your provided input
path_dict_1 = {
    "a": {"age": 90},
    "a/b": {"age": 65},
    "a/c": {"age": 60},
    "a/b/d": {"age": 40},
    "a/c/f": {"age": 38},
    "a/b/e/h": {"age": 6},
    }

path_dict_2 = {
    "a": {"colour": "green"},
    "a/b": {"colour": "pink"},
    "a/c": {"colour": "ult…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@chhei
Comment options

@kayjan
Comment options

@kayjan
Comment options

@chhei
Comment options

Answer selected by chhei
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants