Skip to content

[Python] Guarantee that group_by has stable ordering. #36709

Description

@coady

Describe the enhancement requested

As far as I can tell, it's not officially documented that grouping maintains the order of its keys, but it has seemed that way until recently. Starting with 13.0.0.dev, I've noticed ordering changes intermittently. I think this is an important feature of grouping, as with sorting.

This example outputs differences reliably on 13.0.0.dev516.

importpyarrowaspaarray=pa.chunked_array([list('aba'), list('bcb')])
table=pa.table({'key': array})
foriinrange(100):
groups=table.group_by(['key']).aggregate([])
ifgroups['key'].to_pylist() !=list('abc'):
print(i, groups['key'])

Component(s)

C++, Python

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions