From 8ca2f3a0c5279d6ad0ec042d04a2310c2d286231 Mon Sep 17 00:00:00 2001 From: cirun Date: Thu, 10 Oct 2024 09:13:48 +0200 Subject: [PATCH] LLCAXCHZF-61/handles cases where CKAN type guessing is disabled --- ckanext/charts/fetchers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ckanext/charts/fetchers.py b/ckanext/charts/fetchers.py index d701b1f..64b0c73 100644 --- a/ckanext/charts/fetchers.py +++ b/ckanext/charts/fetchers.py @@ -79,8 +79,9 @@ def fetch_data(self) -> pd.DataFrame: df[non_datetime_cols] = df[non_datetime_cols].apply(pd.to_numeric, errors='ignore').fillna(0) if "date_time" in df.columns: - # Convert the 'date_time' column to string format in ISO 8601 - df['date_time'] = df['date_time'].dt.strftime("%Y-%m-%dT%H:%M:%S") + # Ensure datetime type consistency and format to ISO 8601 + # Handles cases where CKAN type guessing is disabled + df['date_time'] = pd.to_datetime(df['date_time']).dt.strftime("%Y-%m-%dT%H:%M:%S") except (ProgrammingError, UndefinedTable) as e: raise exception.DataFetchError(