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"Contrast — thesametz-awarevaluesconvertcorrectlywhennotwrappedinaCategorical:
pa.array(cats, from_pandas=True).type# timestamp[us, tz=US/Eastern] ← tz preservedComponent(s)
Python
Describe the bug, including details regarding any error messages, version, and platform.
Component(s)
Python