diff --git a/pychunkedgraph/app/__init__.py b/pychunkedgraph/app/__init__.py index 07c47c6db..89c002e9b 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 a2816fb56..52a8e6c4d 100644 --- a/pychunkedgraph/app/segmentation/v1/routes.py +++ b/pychunkedgraph/app/segmentation/v1/routes.py @@ -177,7 +177,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 ------------------------------------------------------------------- @@ -380,7 +380,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"]) @@ -405,7 +405,8 @@ def tabular_change_log(table_id, root_id): if disp: return tab_change_log.to_html() else: - return tab_change_log.to_json() + return jsonify_with_kwargs(tab_change_log) + @bp.route("/table//tabular_change_log_many", methods=["GET"])