-
-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Describe the issue
When upgrading from bigtree version 0.16.2 to 0.17.0, using the dataframe_to_tree function where certain values in the DataFrame are 0 results in nodes that don't have that attribute. In other words, if a value is zero in the DataFrame, it doesn't show up at all as an attribute in the node.
I see this note in the changelog:
Tree Constructor: dataframe_to_tree ignore existing name column, ignore non-attribute columns,
ignore null attribute columns.
So it seems to me 0 is being interpreted as null? If this is the desired behavior, is there a way around it?
Environment
- Platform: Windows 11
- Python version: 3.10.13
bigtreeversion: 0.17.0
To Reproduce
Here's an example that reproduces the issue:
import pandas as pd
from bigtree import dataframe_to_tree
# Create a DataFrame with some zero values
df = pd.DataFrame({
'full_path': ['a', 'a/b', 'a/c'],
'value': [1, 0, 2]
})
# Convert the DataFrame to a tree
tree = dataframe_to_tree(df)
assert hasattr(tree, 'value')
assert not hasattr(tree.children[0], 'value')
assert hasattr(tree.children[1], 'value')In this example, the second node (corresponding to the second row of the DataFrame) should have an attribute 'value' with a value of 0. However, the attribute 'value' is missing from the node.
Expected behaviour
I expected all values in the DataFrame, including zeros, to be included as attributes in the nodes of the tree. Each node should have an attribute for each row in the DataFrame, and the value of the attribute should be the value in the 'value' column of the corresponding row.
Additional context
This issue only occurs when using bigtree version 0.17.0. When using version 0.16.2, zero values in the DataFrame are correctly included as attributes in the nodes.
Also, thanks for your hardwork on this project! I use it heavily at work!
