diff --git a/pychunkedgraph/app/__init__.py b/pychunkedgraph/app/__init__.py index b6a461707..f4478c0e3 100644 --- a/pychunkedgraph/app/__init__.py +++ b/pychunkedgraph/app/__init__.py @@ -41,6 +41,9 @@ def default(self, obj): elif isinstance(obj, datetime.datetime): return obj.__str__() elif isinstance(obj, pd.DataFrame): + for col, col_dtype in obj.dtypes.items(): + if isinstance(col_dtype, pd.DatetimeTZDtype): + obj[col] = obj[col].map(lambda x: x.timestamp()) return obj.to_json() return json.JSONEncoder.default(self, obj) diff --git a/pychunkedgraph/app/segmentation/v1/routes.py b/pychunkedgraph/app/segmentation/v1/routes.py index 382883d68..710100950 100644 --- a/pychunkedgraph/app/segmentation/v1/routes.py +++ b/pychunkedgraph/app/segmentation/v1/routes.py @@ -193,7 +193,7 @@ def handle_user_operations(table_id): if disp: return user_operations.to_html() else: - return user_operations.to_json() + return jsonify_with_kwargs(user_operations) ### GET ROOT ------------------------------------------------------------------- @@ -398,7 +398,7 @@ def tabular_change_log_weekly(table_id): if disp: return weekly_tab_change_log.to_html() else: - return weekly_tab_change_log.to_json() + return jsonify_with_kwargs(weekly_tab_change_log) @bp.route("/table//root//change_log", methods=["GET"]) @@ -422,7 +422,7 @@ def tabular_change_log(table_id, root_id): tab_change_log = tab_change_log_dict[int(root_id)] if disp: return tab_change_log.to_html() - return tab_change_log.to_json() + return jsonify_with_kwargs(tab_change_log) @bp.route("/table//tabular_change_log_many", methods=["GET"])