From 5de8d0dad984c0f4c9c09e566204772eace5b070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20M=C3=BChlbauer?= Date: Mon, 16 Dec 2024 14:56:01 +0100 Subject: [PATCH] fix empty array --- xarray/core/variable.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/core/variable.py b/xarray/core/variable.py index d9f3998c9a6..496f956990f 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -219,6 +219,7 @@ def _possibly_convert_objects(values): if ( values.dtype.kind == "O" and as_series.dtype.kind == "O" + and as_series.size > 0 and isinstance(as_series[0], datetime | pd.Timestamp) ): as_series = as_series.astype("=M8[us]")