Skip to content

Commit a7319e4

Browse files
committed
fix: check if column exists before using astype
1 parent 809f0f8 commit a7319e4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mapswipe_workers/mapswipe_workers/utils/spatial_sampling.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,10 @@ def spatial_sampling(df, interval_length):
143143

144144
if interval_length:
145145
sequence_df = filter_points(sequence_df, interval_length)
146-
# below line prevents FutureWarning
147-
# (https://stackoverflow.com/questions/73800841/add-series-as-a-new-row-into-dataframe-triggers-futurewarning)
148-
sequence_df["is_pano"] = sequence_df["is_pano"].astype(bool)
146+
if "is_pano" in sequence_df.columns:
147+
# below line prevents FutureWarning
148+
# (https://stackoverflow.com/questions/73800841/add-series-as-a-new-row-into-dataframe-triggers-futurewarning)
149+
sequence_df["is_pano"] = sequence_df["is_pano"].astype(bool)
149150
sampled_sequence_df = pd.concat([sampled_sequence_df, sequence_df], axis=0)
150151

151152
# reverse order such that sequence are in direction of travel

0 commit comments

Comments
 (0)