Skip to content

Commit

Permalink
Convert the 'date_time' column to string format in ISO 8601
Browse files Browse the repository at this point in the history
  • Loading branch information
TomeCirun committed Jul 26, 2024
1 parent 936d6fe commit 5946d93
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ckanext/charts/fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def fetch_data(self) -> pd.DataFrame:
# Apply numeric conversion only to non-datetime columns
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")

except (ProgrammingError, UndefinedTable) as e:
raise exception.DataFetchError(
f"An error occurred during fetching data from DataStore: {e}",
Expand Down

0 comments on commit 5946d93

Please sign in to comment.