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])