westonpace commented on a change in pull request #79:
URL: https://github.com/apache/arrow-cookbook/pull/79#discussion_r720488071
##########
File path: python/source/data.rst
##########
@@ -137,3 +137,57 @@ function
.. testoutput::
0 .. 198
+
+Searching for values matching a predicate in Arrays
+---------------------------------------------------
+
+If you have to look for values matching a predicate in Arrow arrays
+the :mod:`arrow.compute` module provides a bunch of predicates that
+can be used to find the values you are looking for.
Review comment:
```suggestion
If you have to look for values matching a predicate in Arrow arrays
the :mod:`arrow.compute` module provides several methods that
can be used to find the values you are looking for.
```
"a bunch of" is a little informal. Function might be a better word than
method, I'm not sure. I think we should distinguish between "predicate" (the
condition we want satisfied) and "method/function" (the tool we use to figure
out what satisfies that condition). A method/function can be a predicate but I
think it should return a bool (and not an array of bool) in that case. For
example `lambda x: x > 10` is a predicate but `filter(lambda x: x > 10,
my_list)` is not.
##########
File path: python/source/data.rst
##########
@@ -137,3 +137,57 @@ function
.. testoutput::
0 .. 198
+
+Searching for values matching a predicate in Arrays
+---------------------------------------------------
+
+If you have to look for values matching a predicate in Arrow arrays
+the :mod:`arrow.compute` module provides a bunch of predicates that
+can be used to find the values you are looking for.
+
+For example, given and array with numbers from 0 to 9, if we
+want to look only for those greater than 5 we could use the
+func:`arrow.compute.greater` predicate and get back the elements
Review comment:
```suggestion
func:`arrow.compute.greater` method and get back the elements
```
##########
File path: python/source/data.rst
##########
@@ -137,3 +137,57 @@ function
.. testoutput::
0 .. 198
+
+Searching for values matching a predicate in Arrays
+---------------------------------------------------
+
+If you have to look for values matching a predicate in Arrow arrays
+the :mod:`arrow.compute` module provides a bunch of predicates that
+can be used to find the values you are looking for.
+
+For example, given and array with numbers from 0 to 9, if we
Review comment:
```suggestion
For example, given an array with numbers from 0 to 9, if we
```
##########
File path: python/source/data.rst
##########
@@ -137,3 +137,57 @@ function
.. testoutput::
0 .. 198
+
+Searching for values matching a predicate in Arrays
+---------------------------------------------------
+
+If you have to look for values matching a predicate in Arrow arrays
+the :mod:`arrow.compute` module provides a bunch of predicates that
+can be used to find the values you are looking for.
+
+For example, given and array with numbers from 0 to 9, if we
+want to look only for those greater than 5 we could use the
+func:`arrow.compute.greater` predicate and get back the elements
+that fit our predicate
+
+.. testcode::
+
+ import pyarrow as pa
+ import pyarrow.compute as pc
+
+ arr = pa.array(range(10))
+ gtfive = pc.greater(arr, 5)
+
+ print(gtfive.to_string())
+
+.. testoutput::
+
+ [
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true,
+ true,
+ true,
+ true
+ ]
+
+Further more we can filter the array to get only the entries
Review comment:
```suggestion
Furthermore we can filter the array to get only the entries
```
--
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]