Skip to content

[Python] Timezone being dropped in dictionary array #49875

Description

@galipremsagar

Describe the bug, including details regarding any error messages, version, and platform.

importpandasaspdimportpyarrowaspacats=pd.DatetimeIndex(["2024-01-01", "2024-01-02"]).tz_localize("US/Eastern")
cat=pd.Categorical(values=[cats[0], cats[1], cats[0]], categories=cats)
# pandas keeps the tz on the categoriesassertstr(cat.dtype.categories.dtype) =="datetime64[us, US/Eastern]"arr=pa.array(cat, from_pandas=True)
print(arr.type) # dictionary<values=timestamp[us], indices=int8, ordered=0>print(arr.type.value_type) # timestamp[us] ← tz droppedassertarr.type.value_type.tzisnotNone, "BUG: tz dropped from dictionary value_type"Contrastthesametz-awarevaluesconvertcorrectlywhennotwrappedinaCategorical:
pa.array(cats, from_pandas=True).type# timestamp[us, tz=US/Eastern] ← tz preserved

Component(s)

Python

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions