amol- commented on a change in pull request #11624:
URL: https://github.com/apache/arrow/pull/11624#discussion_r748397868
##########
File path: python/pyarrow/tests/test_table.py
##########
@@ -1746,3 +1746,56 @@ def test_table_select():
result = table.select(['f2'])
expected = pa.table([a2], ['f2'])
assert result.equals(expected)
+
+
+def test_table_group_by():
+ table = pa.table([
+ pa.array([1, 2, 3, 4, 5]),
+ pa.array(["a", "a", "b", "b", "c"]),
+ pa.array([10, 20, 30, 40, 50])
+ ], names=["values", "keys", "bigvalues"])
+
+ r = table.group_by("keys", ["values"], "hash_sum")
+ assert r.to_pydict() == {
+ "key": ["a", "b", "c"],
+ "values_sum": [3, 7, 5]
+ }
Review comment:
Isn't that something the test would catch if it ever changes? You would
end up with the values for the key into the aggregation result and viceversa if
the order of the columns we emit ever changes.
I added a test case where the aggregations are reversed and it still passes,
at the moment the function always output the aggregations in the order you
provided them.
--
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]