Skip to content

Commit

Permalink
v0.7.4 fix SettingwithCopyWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
kayjan committed Feb 27, 2023
1 parent dd03f3f commit 6544873
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.4] - 2023-02-27
### Fixed
- Tree Construct: Fixed pandas SettingwithCopyWarning when performing dataframe operations.

## [0.7.3] - 2023-02-25
### Added
- Tree Export: Fixed `print_tree` checking attributes with `hasattr` to handle cases of null or 0 value attributes, add more test cases.
Expand Down Expand Up @@ -199,6 +203,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Utility Iterator: Tree traversal methods.
- Workflow To Do App: Tree use case with to-do list implementation.

[0.7.3]: https://github.com/kayjan/bigtree/compare/v0.7.3...v0.7.4
[0.7.3]: https://github.com/kayjan/bigtree/compare/v0.7.2...v0.7.3
[0.7.2]: https://github.com/kayjan/bigtree/compare/v0.7.1...v0.7.2
[0.7.1]: https://github.com/kayjan/bigtree/compare/v0.7.0...v0.7.1
Expand Down
2 changes: 1 addition & 1 deletion bigtree/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.7.3"
__version__ = "0.7.4"

from bigtree.binarytree.construct import list_to_binarytree
from bigtree.dag.construct import dataframe_to_dag, dict_to_dag, list_to_dag
Expand Down
2 changes: 2 additions & 0 deletions bigtree/dag/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def dataframe_to_dag(
Returns:
(DAGNode)
"""
data = data.copy()

if not len(data.columns):
raise ValueError("Data does not contain any columns, check `data`")
if not len(data):
Expand Down
2 changes: 1 addition & 1 deletion bigtree/dag/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def dag_to_dataframe(
all_attrs (bool): indicator whether to retrieve all `Node` attributes
Returns:
(pd.DataFrame)
(pandas.DataFrame)
"""
dag = dag.copy()
data_list = []
Expand Down
8 changes: 8 additions & 0 deletions bigtree/tree/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ def add_dataframe_to_tree_by_path(
Returns:
(Node)
"""
data = data.copy()

if not len(data.columns):
raise ValueError("Data does not contain any columns, check `data`")
if not len(data):
Expand Down Expand Up @@ -359,6 +361,8 @@ def add_dataframe_to_tree_by_name(
Returns:
(Node)
"""
data = data.copy()

if join_type not in ["inner", "left"]:
raise ValueError("`join_type` must be one of 'inner' or 'left'")

Expand Down Expand Up @@ -755,6 +759,8 @@ def dataframe_to_tree(
Returns:
(Node)
"""
data = data.copy()

if not len(data.columns):
raise ValueError("Data does not contain any columns, check `data`")
if not len(data):
Expand Down Expand Up @@ -848,6 +854,8 @@ def dataframe_to_tree_by_relation(
Returns:
(Node)
"""
data = data.copy()

if not len(data.columns):
raise ValueError("Data does not contain any columns, check `data`")
if not len(data):
Expand Down
2 changes: 1 addition & 1 deletion bigtree/tree/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def tree_to_dataframe(
leaf_only (bool): indicator to retrieve only information from leaf nodes
Returns:
(pd.DataFrame)
(pandas.DataFrame)
"""
tree = tree.copy()
data_list = []
Expand Down

0 comments on commit 6544873

Please sign in to comment.