JeromeLovy opened a new issue, #15027:
URL: https://github.com/apache/arrow/issues/15027

   ### Describe the usage question you have. Please include as many useful 
details as  possible.
   
   
   Hello,
   
   I'm trying to perform "filtering by expressions" with pyarrow, by testing 
the code samples found in the [Compute 
Functions](https://arrow.apache.org/docs/python/compute.html#filtering-by-expressions)
 documentation or in the 
[pyarrow.Table.filter](https://arrow.apache.org/docs/python/generated/pyarrow.Table.html#pyarrow.Table.filter)
 reference.
   
   Example 1:
   ```
   import pyarrow as pa
   import pyarrow.compute as pc
   even_filter = (pc.bit_wise_and(pc.field("nums"), pc.scalar(1)) == 
pc.scalar(0))
   table = pa.table({'nums': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
                     'chars': ["a", "b", "c", "d", "e", "f", "g", "h", "i", 
"l"]})
   table.filter(even_filter)
   ```
   
   Example 2:
   ```
   import pyarrow as pa
   import pandas as pd
   
   df = pd.DataFrame({'year': [2020, 2022, 2019, 2021],
                      'n_legs': [2, 4, 5, 100],
                      'animals': ["Flamingo", "Horse", "Brittle stars", 
"Centipede"]})
   table = pa.Table.from_pandas(df)
   table.filter(expr)
   ```
   
   Both examples fail with following exception, apparently raised in 
`_pack_compute_args()` in `pyarrow/_compute.pyx`:
   ```
   TypeError: Got unexpected argument type <class 
'pyarrow._compute.Expression'> for compute function
   ```
   
   Am I doing something wrong?
   Is the documented behavior (Filtering by Expressions) really implemented?
   (In `pyarrow/_compute.pyx`, the Cython code for `_pack_compute_args()` 
doesn't seem to allow an Expression as argument indeed.)
   
   Thanks in advance.
   Best,
   Jérôme
   
   ### Component(s)
   
   Python


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