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(