Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dt units in empty() (tz path) #893

Merged
merged 3 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions fastparquet/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from pandas import (
Categorical, DataFrame, Series,
CategoricalIndex, RangeIndex, Index, MultiIndex,
DatetimeIndex, CategoricalDtype
DatetimeIndex, CategoricalDtype,
DatetimeTZDtype
)
from pandas.core.arrays.masked import BaseMaskedDtype
import warnings
Expand Down Expand Up @@ -195,9 +196,10 @@ 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)
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)
else:
if not isinstance(bvalues, np.ndarray):
# e.g. DatetimeLikeBlock backed by DatetimeArray/TimedeltaArray
Expand Down
Loading