Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion python/pyarrow/src/arrow/python/arrow_to_pandas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2404,9 +2404,11 @@ class ConsolidatedBlockCreator : public PandasBlockCreator {

Status CreateBlocks() {
for (int i = 0; i < num_columns_; ++i) {
const DataType& type = *arrays_[i]->type();
PandasWriter::type output_type;
RETURN_NOT_OK(GetBlockType(i, &output_type));
// GetBlockType may replace the column (extension storage, decoded
// run-end encoding), so take the type afterwards.
const DataType& type = *arrays_[i]->type();

int block_placement = 0;
std::shared_ptr<PandasWriter> writer;
Expand Down
10 changes: 10 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4356,6 +4356,16 @@ def test_run_end_encoded_to_pandas():
ree_array.to_pandas(zero_copy_only=True)


@pytest.mark.pandas
def test_run_end_encoded_timestamp_tz_table_to_pandas():
# GH-55837: the pandas writer must see the decoded type
import pandas as pd
arr = pa.array([0, 0, 3600, None], pa.timestamp('s', tz='Europe/Brussels'))
result = pa.table({'c': pc.run_end_encode(arr)}).to_pandas()
expected = pa.table({'c': arr}).to_pandas()
pd.testing.assert_frame_equal(result, expected)


@pytest.mark.parametrize(('list_array_type', 'list_type_factory'),
[(pa.ListViewArray, pa.list_view),
(pa.LargeListViewArray, pa.large_list_view)])
Expand Down