Skip to content

Commit

Permalink
LLCAXCHZF-55/prevent datetime columns from being converted to large n…
Browse files Browse the repository at this point in the history
…umeric values
  • Loading branch information
TomeCirun committed Jul 24, 2024
1 parent a100082 commit 94fd4a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ckanext/charts/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def fetch_data(self) -> pd.DataFrame:
get_read_engine(),
).drop(columns=["_id", "_full_text"])

# TODO: hack... Convert all columns to numeric if possible
df = cast(pd.DataFrame, df.apply(pd.to_numeric, errors='ignore').fillna(0))
# Identify columns that are not datetime
non_datetime_cols = df.select_dtypes(exclude=['datetime']).columns
# Apply numeric conversion only to non-datetime columns
df[non_datetime_cols] = df[non_datetime_cols].apply(pd.to_numeric, errors='ignore').fillna(0)

except (ProgrammingError, UndefinedTable) as e:
raise exception.DataFetchError(
Expand Down

0 comments on commit 94fd4a0

Please sign in to comment.