From 6e2e3056d27246d52b8426853d0d7f6129424b12 Mon Sep 17 00:00:00 2001 From: Martin Durant Date: Mon, 23 Oct 2023 09:47:04 -0400 Subject: [PATCH] Use dt units in empty() --- fastparquet/dataframe.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fastparquet/dataframe.py b/fastparquet/dataframe.py index 690ea0ca..d51889d3 100644 --- a/fastparquet/dataframe.py +++ b/fastparquet/dataframe.py @@ -196,8 +196,9 @@ def set_cats(values, i=i, col=col, **kwargs): values = Categorical.from_codes(codes=code, dtype=bvalues.dtype) elif getattr(bvalues.dtype, 'tz', None): - values = np.zeros(shape=shape, dtype='M8[ns]') - values = type(bvalues)(values, dtype=bvalues.dtype) + dt = "M8[ns]" if PANDAS_VERSION.major < 2 else f'M8[{bvalues.dtype.unit}]' + values = np.zeros(shape=shape, dtype=dt) + values = type(bvalues)._from_sequence(values, copy=False, dtype=bvalues.dtype) else: if not isinstance(bvalues, np.ndarray): # e.g. DatetimeLikeBlock backed by DatetimeArray/TimedeltaArray