From f7e7fc65f6d416ecf579665601166ba464f8d278 Mon Sep 17 00:00:00 2001 From: Ben Pedigo Date: Tue, 23 Apr 2024 10:38:37 -0700 Subject: [PATCH] add auto option --- networkframe/networkframe.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/networkframe/networkframe.py b/networkframe/networkframe.py index 2bcb9c3..528e87d 100644 --- a/networkframe/networkframe.py +++ b/networkframe/networkframe.py @@ -1263,7 +1263,7 @@ def k_hop_aggregation( drop_non_numeric=True, n_jobs=-1, verbose=False, - engine="pandas", + engine="auto", ): if k < 0: raise ValueError("k must be non-negative.") @@ -1271,6 +1271,14 @@ def k_hop_aggregation( if isinstance(aggregations, str): aggregations = [aggregations] + if engine == "auto": + if not all([isinstance(x, str) for x in aggregations]) or not all( + [x in ["mean", "sum", "std"] for x in aggregations] + ): + engine = "pandas" + else: + engine = "scipy" + nodes = self.nodes if drop_non_numeric: nodes = nodes.select_dtypes(include=[np.number])