Skip to content

Commit

Permalink
Further _from_sequence (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant authored Oct 26, 2023
1 parent 89acf38 commit 1f90f1a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastparquet/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def set_cats(values, i=i, col=col, **kwargs):
elif isinstance(bvalues.dtype, DatetimeTZDtype):
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)
values = type(bvalues)._from_sequence(values.view("int64"), copy=False, dtype=bvalues.dtype)
else:
if not isinstance(bvalues, np.ndarray):
# e.g. DatetimeLikeBlock backed by DatetimeArray/TimedeltaArray
Expand All @@ -210,7 +210,7 @@ def set_cats(values, i=i, col=col, **kwargs):
elif bvalues.dtype.kind == "M":
dt = "M8[ns]" if PANDAS_VERSION.major < 2 else bvalues.dtype
values = np.zeros(shape=shape, dtype=dt)
values = type(bvalues)._from_sequence(values, copy=False)
values = type(bvalues)._from_sequence(values.view("int64"), copy=False, dtype=bvalues.dtype)
elif str(bvalues.dtype)[0] in {"I", "U"} or str(bvalues.dtype) == "boolean":
arr_type = bvalues.dtype.construct_array_type()
values = arr_type(
Expand Down

0 comments on commit 1f90f1a

Please sign in to comment.