Skip to content

Commit

Permalink
Use dt units in empty()
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed Oct 23, 2023
1 parent 165bec3 commit 6e2e305
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fastparquet/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e2e305

Please sign in to comment.