-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-9967: [Python] Add compute module docs + expose more option classes #8145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
49f9bc1
ARROW-9967: [Python] Add compute module documentation
arw2019 ddd6dad
feedback
arw2019 15edf68
add explicit wrappers for and_ and or_
arw2019 6cf1a0e
linting
arw2019 0814bbd
test some wrappers
arw2019 b7af6d9
more linting
arw2019 f72f100
feedback
arw2019 4d6a7d9
expose PartitionNthOptions
arw2019 d5b9d12
alphabetise func names in Python API reference
arw2019 0b6ad51
__init__ -> __cinit__ in PartitionNthOptions
arw2019 ff7b3b2
explicit typing in PartitionNthOptions
arw2019 359c059
expose SetLookupOptions
arw2019 103a177
expose StrptimeOptions + linting
arw2019 0bcedcf
add link to C++ compute docs
arw2019 38346a3
expose stddev & variance kernels
arw2019 08429f2
linting
arw2019 8d81df2
don't use unique_ptr in VarianceOptions
arw2019 73237b0
Improve docs and tests a bit
pitrou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ API Reference | |
| api/datatypes | ||
| api/arrays | ||
| api/memory | ||
| api/compute | ||
| api/files | ||
| api/tables | ||
| api/ipc | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| .. Licensed to the Apache Software Foundation (ASF) under one | ||
| .. or more contributor license agreements. See the NOTICE file | ||
| .. distributed with this work for additional information | ||
| .. regarding copyright ownership. The ASF licenses this file | ||
| .. to you under the Apache License, Version 2.0 (the | ||
| .. "License"); you may not use this file except in compliance | ||
| .. with the License. You may obtain a copy of the License at | ||
|
|
||
| .. http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| .. Unless required by applicable law or agreed to in writing, | ||
| .. software distributed under the License is distributed on an | ||
| .. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| .. KIND, either express or implied. See the License for the | ||
| .. specific language governing permissions and limitations | ||
| .. under the License. | ||
|
|
||
| .. _api.compute: | ||
| .. currentmodule:: pyarrow.compute | ||
|
|
||
| Compute Functions | ||
| ================= | ||
|
|
||
| Aggregations | ||
| ------------ | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| count | ||
| mean | ||
| min_max | ||
| mode | ||
| stddev | ||
| sum | ||
| variance | ||
|
|
||
| Arithmetic Functions | ||
| -------------------- | ||
|
|
||
| By default these functions do not detect overflow. Each function is also | ||
| available in an overflow-checking variant, suffixed ``_checked``, which | ||
| throws an ``ArrowInvalid`` exception when overflow is detected. | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| add | ||
| add_checked | ||
| divide | ||
| divide_checked | ||
| multiply | ||
| multiply_checked | ||
| subtract | ||
| subtract_checked | ||
|
|
||
| Comparisons | ||
| ----------- | ||
|
|
||
| These functions expect two inputs of the same type. If one of the inputs is `null` | ||
| they return ``null``. | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| equal | ||
| greater | ||
| greater_equal | ||
| less | ||
| less_equal | ||
| not_equal | ||
|
|
||
| Logical Functions | ||
| ----------- | ||
|
|
||
| These functions normally emit a null when one of the inputs is null. However, Kleene | ||
| logic variants are provided (suffixed ``_kleene``). See User Guide for details. | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| and_ | ||
| and_kleene | ||
| invert | ||
| or_ | ||
| or_kleene | ||
| xor | ||
|
|
||
| String Predicates | ||
| ----------------- | ||
|
|
||
| In these functions an empty string emits false in the output. For ASCII | ||
| variants (prefixed ``ascii_``) a string element with non-ASCII characters | ||
| emits false in the output. | ||
|
|
||
| The first set of functions emit true if the input contains only | ||
| characters of a given class. | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| ascii_is_alnum | ||
| ascii_is_alpha | ||
| ascii_is_decimal | ||
| ascii_is_lower | ||
| ascii_is_printable | ||
| ascii_is_space | ||
| ascii_is_upper | ||
| utf8_is_alnum | ||
| utf8_is_alpha | ||
| utf8_is_decimal | ||
| utf8_is_digit | ||
| utf8_is_lower | ||
| utf8_is_numeric | ||
| utf8_is_printable | ||
| utf8_is_space | ||
| utf8_is_upper | ||
|
|
||
| The second set of functions also consider the order of characters | ||
| in the string element. | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| ascii_is_title | ||
| utf8_is_title | ||
|
|
||
| The third set of functions examines string elements on | ||
| a byte-by-byte basis. | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| string_is_ascii | ||
|
|
||
| String Transforms | ||
| ----------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| ascii_lower | ||
| ascii_upper | ||
| utf8_lower | ||
| utf8_upper | ||
|
|
||
| Containment tests | ||
| ----------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| index_in | ||
| is_in | ||
| match_substring | ||
|
|
||
| Conversions | ||
| ----------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| cast | ||
| strptime | ||
|
|
||
| Selections | ||
| ---------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| filter | ||
| take | ||
|
|
||
| Associative transforms | ||
| ---------------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| dictionary_encode | ||
| unique | ||
| value_counts | ||
|
|
||
| Sorts and partitions | ||
| -------------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| partition_nth_indices | ||
| sort_indices | ||
|
|
||
| Structural Transforms | ||
| --------------------- | ||
|
|
||
| .. autosummary:: | ||
| :toctree: ../generated/ | ||
|
|
||
| binary_length | ||
| fill_null | ||
| is_null | ||
| is_valid | ||
| list_value_length | ||
| list_flatten | ||
| list_parent_indices | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| .. Licensed to the Apache Software Foundation (ASF) under one | ||
| .. or more contributor license agreements. See the NOTICE file | ||
| .. distributed with this work for additional information | ||
| .. regarding copyright ownership. The ASF licenses this file | ||
| .. to you under the Apache License, Version 2.0 (the | ||
| .. "License"); you may not use this file except in compliance | ||
| .. with the License. You may obtain a copy of the License at | ||
|
|
||
| .. http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| .. Unless required by applicable law or agreed to in writing, | ||
| .. software distributed under the License is distributed on an | ||
| .. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| .. KIND, either express or implied. See the License for the | ||
| .. specific language governing permissions and limitations | ||
| .. under the License. | ||
|
|
||
| .. currentmodule:: pyarrow.compute | ||
| .. _compute: | ||
|
|
||
| ================= | ||
| Compute Functions | ||
| ================= | ||
|
|
||
| Arrow supports logical compute operations over inputs of possibly | ||
arw2019 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| varying types. Many compute functions support both array (chunked or not) | ||
| and scalar inputs, but some will mandate either. For example, | ||
| the ``fill_null`` function requires its second input to be a scalar, | ||
| while ``sort_indices`` requires its first and only input to | ||
| be an array. | ||
|
|
||
| Below are a few simple examples: | ||
|
|
||
| >>> import pyarrow as pa | ||
| >>> import pyarrow.compute as pc | ||
| >>> a = pa.array([1, 1, 2, 3]) | ||
| >>> pc.sum(a) | ||
| <pyarrow.Int64Scalar: 7> | ||
| >>> b = pa.array([4, 1, 2, 8]) | ||
| >>> pc.equal(a, b) | ||
| <pyarrow.lib.BooleanArray object at 0x7f686e4eef30> | ||
| [ | ||
| false, | ||
| true, | ||
| true, | ||
| false | ||
| ] | ||
| >>> x, y = pa.scalar(7.8), pa.scalar(9.3) | ||
| >>> pc.multiply(x, y) | ||
| <pyarrow.DoubleScalar: 72.54> | ||
|
|
||
|
|
||
| .. seealso:: | ||
|
|
||
| :ref:`Available compute functions (C++ documentation) <compute-function-list>`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ files into Arrow structures. | |
| install | ||
| memory | ||
| data | ||
| compute | ||
| ipc | ||
| filesystems | ||
| filesystems_deprecated | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this render the docstrings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. It's what's done on the other pages:
https://github.com/apache/arrow/blob/master/docs/source/python/api/datatypes.rst
I'm having trouble building the docs locally (related to ARROW-10018 I think) so haven't been able to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't render the docstring here, but it will create a separate page for each of those functions and link to that from this table.
(the separate pages might be a bit overkill since the docstrings here are often not that informative yet, but it's indeed how we do it for other functions as well)