MatthewRGonzalez commented on issue #13747:
URL: https://github.com/apache/arrow/issues/13747#issuecomment-1685144145

   Thanks, @amol! I'm still experimenting but the following worked:
   
   ```
   import pyarrow as pa
   import pyarrow.acero as ac
   import pyarrow.dataset as ds
   
   def _group_by(table_or_dataset, aggregates, keys):
   
       if isinstance(table_or_dataset, ds.Dataset):
           data_source = ac._dataset_to_decl(table_or_dataset, use_threads=True)
       else:
           data_source = ac.Declaration(
               "table_source", ac.TableSourceNodeOptions(table_or_dataset)
           )
       decl = ac.Declaration.from_sequence([data_source, 
ac.Declaration("aggregate", ac.AggregateNodeOptions(aggregates, keys = keys)) ])
       return(decl.to_table(use_threads=True))
   
   
   ## dataset from below table
   # table = pa.table({'a': [1, 1, 2,2,3], 'b': [4, 5, 6,7,8]})
   dataset = ds.dataset("my_data")
   
   _group_by(dataset,[("b", "hash_sum", None, "b_sum")], keys = "e")
   
   ```


-- 
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