AnkitAhlawat7742 commented on code in PR #49878:
URL: https://github.com/apache/arrow/pull/49878#discussion_r3182688720


##########
python/pyarrow/tests/test_pandas.py:
##########
@@ -492,6 +492,22 @@ def test_categorical_row_index(self):
 
         _check_pandas_roundtrip(df, preserve_index=True)
 
+    def test_categorical_with_timezone(self):
+        # pandas Categorical with timezone-aware datetime categories
+        # GH-49875: timezone was dropped when converting tz-aware categorical
+        cats = pd.DatetimeIndex(["2024-01-01", 
"2024-01-02"]).tz_localize("US/Eastern")
+        cat = pd.Categorical(values=[cats[0], cats[1], cats[0]], 
categories=cats)
+
+        # Verify pandas keeps the timezone on categories
+        assert "US/Eastern" in str(cat.dtype.categories.dtype)
+
+        # Convert to PyArrow
+        arr = pa.array(cat, from_pandas=True)
+
+        # Verify timezone is preserved in the dictionary value type
+        assert arr.type.value_type.tz is not None
+        assert str(arr.type.value_type.tz) == "US/Eastern"

Review Comment:
   Thanks for the Review 
   Code has been updated as per the review comment 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to