From 7f29c31abe6cf133f28f4b4558cccb7f20899d72 Mon Sep 17 00:00:00 2001 From: martacki Date: Thu, 24 Mar 2022 13:17:01 +0100 Subject: [PATCH] .copy() shortcut --- scripts/cluster_network.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index 9c6d541f..f659f8a8 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -269,10 +269,7 @@ def busmap_for_n_clusters(n, n_clusters, solver_name, focus_weights=None, algori # overwrite country of nodes that are disconnected from their country-topology for country in n.buses.country.unique(): - m = n.copy() - m.buses = m.buses.query("country in @country") - m.lines = m.lines.query("bus0 in @m.buses.index and bus1 in @m.buses.index") - m.links = m.links.query("bus0 in @m.buses.index and bus1 in @m.buses.index") + m = n[n.buses.country ==country].copy() _, labels = csgraph.connected_components(m.adjacency_matrix(), directed=False)