From 42e8ac4de9b268c2a3395cb7632383fad1e814e6 Mon Sep 17 00:00:00 2001 From: Cullen Watson Date: Mon, 18 Sep 2023 22:24:14 -0500 Subject: [PATCH] fix: drop dups if cols exist --- homeharvest/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeharvest/__init__.py b/homeharvest/__init__.py index e2f7f2a..2114641 100644 --- a/homeharvest/__init__.py +++ b/homeharvest/__init__.py @@ -157,5 +157,8 @@ def scrape_property( return pd.DataFrame() final_df = pd.concat(results, ignore_index=True) - final_df = final_df.drop_duplicates(subset=["street_address", "city", "unit"], keep="first") + dupe_check_columns = ["street_address", "city", "unit"] + if all(col in final_df.columns for col in dupe_check_columns): + final_df = final_df.drop_duplicates(subset=dupe_check_columns, keep="first") + return final_df \ No newline at end of file