Skip to content

Commit ecdc560

Browse files
authored
BUG: fix extraction of ids if there is only a single hit when retrieving point level data in Streetscape (#671)
1 parent 4550d91 commit ecdc560

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

momepy/streetscape.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,10 +2115,10 @@ def point_level(self) -> gpd.GeoDataFrame:
21152115

21162116
point_data = point_data.explode(point_data.columns.tolist())
21172117
point_data["left_ids"] = point_data["left_ids"].apply(
2118-
lambda x: {c for c in x if not pd.isna(c)}
2118+
lambda x: {c for c in x if not pd.isna(c)} if isinstance(x, list) else {x}
21192119
)
21202120
point_data["right_ids"] = point_data["right_ids"].apply(
2121-
lambda x: {c for c in x if not pd.isna(c)}
2121+
lambda x: {c for c in x if not pd.isna(c)} if isinstance(x, list) else {x}
21222122
)
21232123
point_data = point_data.rename(
21242124
columns={"left_ids": "left_seq_sb_index", "right_ids": "right_seq_sb_index"}
@@ -2212,10 +2212,18 @@ def point_level(self) -> gpd.GeoDataFrame:
22122212

22132213
point_data["left_plot_seq_sb_index"] = point_data[
22142214
"left_plot_seq_sb_index"
2215-
].apply(lambda x: {c for c in x if not pd.isna(c)})
2215+
].apply(
2216+
lambda x: {c for c in x if not pd.isna(c)}
2217+
if isinstance(x, list)
2218+
else {x}
2219+
)
22162220
point_data["right_plot_seq_sb_index"] = point_data[
22172221
"right_plot_seq_sb_index"
2218-
].apply(lambda x: {c for c in x if not pd.isna(c)})
2222+
].apply(
2223+
lambda x: {c for c in x if not pd.isna(c)}
2224+
if isinstance(x, list)
2225+
else {x}
2226+
)
22192227
inds.extend(
22202228
[
22212229
"plot_seq_sb",

0 commit comments

Comments
 (0)