From d97ba9212abc3959f138771d9f0e13888c3de73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Fri, 6 Oct 2023 19:40:21 +0200 Subject: [PATCH] Handle dtype as dt.datetime or dt.date --- holonote/annotate/table.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/holonote/annotate/table.py b/holonote/annotate/table.py index 2dee152..f1dc540 100644 --- a/holonote/annotate/table.py +++ b/holonote/annotate/table.py @@ -1,5 +1,6 @@ from __future__ import annotations +import datetime as dt from typing import TYPE_CHECKING, Any import pandas as pd @@ -244,7 +245,7 @@ def _empty_expanded_region_df(self, *, spec: SpecDict, dims: list[str] | None) - columns, types = [], [] for dim in dims: region = spec[dim]["region"] - dtype = spec[dim]["type"]() + dtype = pd.NaT if isinstance(t := spec[dim]["type"], dt.date) else t() if region == "range": columns.extend([f"start[{dim}]", f"end[{dim}]"]) types.extend([dtype, dtype])