Bigtree is a Python library that provides a performant, flexible, and intuitive implementation for tree data structures. It supports various tree types (Tree, Binary Tree, Directed Acyclic Graph) and offers a rich API for traversal, search, modification, and export. It integrates seamlessly with Python lists, dictionaries, pandas, and polars DataFrames, making it suitable for a wide range of hierarchical data workflows. The library is actively maintained with frequent releases, currently at version 1.4.0.
pip install bigtreeVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to create a basic tree using `Node` objects and print its structure to the console using `print_tree`. It also shows how to access built-in node attributes like `is_leaf` and `node_name`.
Ensure node names do not contain path separator characters (e.g., '/', '\\', or custom separators if configured).
Review existing `get_attr` calls. If you previously handled `AttributeError` for missing attributes, consider using the `default` parameter of `get_attr` (e.g., `node.get_attr('missing_attr', None)`). Be aware of new nested attribute access capabilities.Consult the official `bigtree` documentation and changelog, particularly for versions 1.0.0 and 1.0.2, if you experience unexpected behavior or `AttributeError` when upgrading from pre-1.0.0 versions, especially for advanced use cases or custom node extensions.
Install the bigtree library using pip: `pip install bigtree`
Adjust existing `get_attr` calls to expect `None` for missing attributes or explicitly provide a `default` value, e.g., `node.get_attr('missing_attr', None)`.Ensure that the `sep` symbol is consistent across all tree objects involved in the operation. If constructing trees manually, pass the same `sep` argument to `Node` or `Tree` constructors. Also, verify that node names themselves do not contain the chosen separator character.
Ensure that all intermediate node names in the input DataFrame are unique. If duplicate intermediate node names are expected and should be handled by creating separate branches, set the `allow_duplicates` parameter to `True` in `dataframe_to_tree_by_relation`.