Skip to content

Commit 1832999

Browse files
committed
export: dropna before KDTree assignment
1 parent b4bb66f commit 1832999

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

powerplantmatching/export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def map_bus(df, buses):
7272
DataFrame with an extra column 'bus' indicating the nearest bus.
7373
"""
7474
df = get_obj_if_Acc(df)
75-
kdtree = KDTree(buses[["x", "y"]])
7675
non_empty_buses = buses.dropna()
76+
kdtree = KDTree(non_empty_buses[["x", "y"]])
7777
if non_empty_buses.empty:
7878
buses_i = pd.Index([np.nan])
7979
else:
@@ -117,7 +117,7 @@ def to_pypsa_network(df, network, buslist=None):
117117
"""
118118
df = get_obj_if_Acc(df)
119119
df = map_bus(df, network.buses.reindex(buslist))
120-
df.Set.replace("CHP", "PP", inplace=True)
120+
df["Set"] = df.Set.replace("CHP", "PP")
121121
if "Duration" in df:
122122
df["weighted_duration"] = df["Duration"] * df["Capacity"]
123123
df = df.groupby(["bus", "Fueltype", "Set"]).aggregate(

0 commit comments

Comments
 (0)