Skip to content

Commit

Permalink
LLCAXCHZF-61/Prevent KeyError when dropping non-existent columns
Browse files Browse the repository at this point in the history
  • Loading branch information
TomeCirun committed Oct 16, 2024
1 parent dec8ed7 commit d0b9191
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ckanext/charts/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ def fetch_data(self) -> pd.DataFrame:
.select_from(sa.table(self.resource_id))
.limit(self.limit),
get_read_engine(),
).drop(columns=["_id", "_full_text"])
)

existing_columns = {col for col in {'_id', '_full_text'} if col in df.columns}
if existing_columns:
df = df.drop(columns=existing_columns)

if "date_time" in df.columns:
try:
Expand Down

0 comments on commit d0b9191

Please sign in to comment.