Skip to content

Commit b4bb66f

Browse files
Merge pull request #146 from PyPSA/future-warning-map_bus
export: re-address future warning
2 parents 82dbbba + 5560199 commit b4bb66f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

powerplantmatching/export.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def map_bus(df, buses):
7373
"""
7474
df = get_obj_if_Acc(df)
7575
kdtree = KDTree(buses[["x", "y"]])
76-
buses_i = buses.index.append(pd.Index([np.nan]))
76+
non_empty_buses = buses.dropna()
77+
if non_empty_buses.empty:
78+
buses_i = pd.Index([np.nan])
79+
else:
80+
buses_i = non_empty_buses.index.append(pd.Index([np.nan]))
7781
return df.assign(bus=buses_i[kdtree.query(df[["lon", "lat"]].values)[1]])
7882

7983

0 commit comments

Comments
 (0)