AlenkaF commented on code in PR #49355:
URL: https://github.com/apache/arrow/pull/49355#discussion_r2894392453


##########
docs/source/python/dataset.rst:
##########
@@ -569,6 +569,29 @@ calculate the average of a column without loading the 
entire column into memory:
     ...     count += batch.num_rows
     >>> mean_a = col2_sum/count
 
+The ``filter`` argument of :meth:`Dataset.to_batches` (and 
:func:`~Dataset.to_table`)
+expects a boolean :class:`~pyarrow.dataset.Expression`, which can be 
constructed using
+:func:`pyarrow.dataset.field` and its operator overloads.  However, if you 
already have
+filters in the DNF (Disjunctive Normal Form) list-of-tuples format accepted by
+:class:`pyarrow.parquet.ParquetDataset`, you can convert them to an 
``Expression``
+using :func:`pyarrow.parquet.filters_to_expression`:
+
+.. code-block:: python
+
+    >>> import pyarrow.parquet as pq
+    >>> import pyarrow.compute as pc
+    >>> dataset = ds.dataset(base / "parquet_dataset", format="parquet")

Review Comment:
   This part also doesn't have to be run again. We could print the table 
though, so it would be more clear what the `a_sum` result means?
   
   ```suggestion
       >>> dataset.to_table(columns=['a'])
   
   ```



##########
docs/source/python/dataset.rst:
##########
@@ -569,6 +569,29 @@ calculate the average of a column without loading the 
entire column into memory:
     ...     count += batch.num_rows
     >>> mean_a = col2_sum/count
 
+The ``filter`` argument of :meth:`Dataset.to_batches` (and 
:func:`~Dataset.to_table`)
+expects a boolean :class:`~pyarrow.dataset.Expression`, which can be 
constructed using
+:func:`pyarrow.dataset.field` and its operator overloads.  However, if you 
already have
+filters in the DNF (Disjunctive Normal Form) list-of-tuples format accepted by
+:class:`pyarrow.parquet.ParquetDataset`, you can convert them to an 
``Expression``
+using :func:`pyarrow.parquet.filters_to_expression`:
+
+.. code-block:: python
+
+    >>> import pyarrow.parquet as pq
+    >>> import pyarrow.compute as pc

Review Comment:
   ```suggestion
   ```
   
   These can be removed as we have imported them above. IMHO the code is 
clearer if we do not repeat the imports.



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