diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi index a09766fd4b777..8a8edd88b47e9 100644 --- a/python/pyarrow/table.pxi +++ b/python/pyarrow/table.pxi @@ -163,7 +163,16 @@ cdef class ChunkedArray(_PandasConvertible): self.sp_chunked_array, self, &out)) - return pandas_api.series(wrap_array_output(out), name=self._name) + result = pandas_api.series(wrap_array_output(out), name=self._name) + + if isinstance(self.type, TimestampType): + tz = self.type.tz + if tz is not None: + tz = string_to_tzinfo(tz) + result = (result.dt.tz_localize('utc') + .dt.tz_convert(tz)) + + return result def __array__(self, dtype=None): values = self.to_pandas().values diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py index 9aa8a7c8b48f9..91ca247aa2796 100644 --- a/python/pyarrow/tests/test_array.py +++ b/python/pyarrow/tests/test_array.py @@ -1786,3 +1786,6 @@ def test_to_pandas_timezone(): arr = pa.array([1, 2, 3], type=pa.timestamp('s', tz='Europe/Brussels')) s = arr.to_pandas() assert s.dt.tz is not None + arr = pa.chunked_array([arr]) + s = arr.to_pandas() + assert s.dt.tz is not None diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py index f9b2092ce0735..434ec8029c1ea 100644 --- a/python/pyarrow/tests/test_table.py +++ b/python/pyarrow/tests/test_table.py @@ -187,15 +187,19 @@ def test_chunked_array_pickle(data, typ): @pytest.mark.pandas def test_chunked_array_to_pandas(): + import pandas as pd + data = [ pa.array([-10, -5, 0, 5, 10]) ] table = pa.table(data, names=['a']) col = table.column(0) assert isinstance(col, pa.ChunkedArray) - array = col.to_pandas() - assert array.shape == (5,) - assert array[0] == -10 + series = col.to_pandas() + assert isinstance(series, pd.Series) + assert series.shape == (5,) + assert series[0] == -10 + assert series.name == 'a' @pytest.mark.pandas