This is an automated email from the ASF dual-hosted git repository. altay pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new b4d3474 [BEAM-7389] Add code examples for Keys page new d93f188 Merge pull request #9263 from davidcavazos/keys-page b4d3474 is described below commit b4d3474fac0248b3e2e3908c9b8fc260bcfe2230 Author: David Cavazos <dcava...@google.com> AuthorDate: Fri Aug 2 10:44:07 2019 -0700 [BEAM-7389] Add code examples for Keys page --- .../transforms/python/element-wise/filter.md | 2 +- .../transforms/python/element-wise/keys.md | 58 +++++++++++++++++++--- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/website/src/documentation/transforms/python/element-wise/filter.md b/website/src/documentation/transforms/python/element-wise/filter.md index 420718c..84e00eb 100644 --- a/website/src/documentation/transforms/python/element-wise/filter.md +++ b/website/src/documentation/transforms/python/element-wise/filter.md @@ -42,7 +42,7 @@ on the comparison ordering of the element. ## Examples -In the following examples, we create a pipeline with a `PCollection` of produce their icon, name, and duration. +In the following examples, we create a pipeline with a `PCollection` of produce with their icon, name, and duration. Then, we apply `Filter` in multiple ways to filter out produce by their duration value. ### Example 1: Filtering with a function diff --git a/website/src/documentation/transforms/python/element-wise/keys.md b/website/src/documentation/transforms/python/element-wise/keys.md index 3265c23..7d3a97c 100644 --- a/website/src/documentation/transforms/python/element-wise/keys.md +++ b/website/src/documentation/transforms/python/element-wise/keys.md @@ -19,21 +19,63 @@ limitations under the License. --> # Keys -<table align="left"> - <a target="_blank" class="button" + +<script type="text/javascript"> +localStorage.setItem('language', 'language-py') +</script> + +<table> + <td> + <a class="button" target="_blank" href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.util.html#apache_beam.transforms.util.Keys"> - <img src="https://beam.apache.org/images/logos/sdks/python.png" width="20px" height="20px" - alt="Pydoc" /> - Pydoc + <img src="https://beam.apache.org/images/logos/sdks/python.png" + width="20px" height="20px" alt="Pydoc" /> + Pydoc </a> + </td> </table> <br> + Takes a collection of key-value pairs and returns the key of each element. -## Examples -See [BEAM-7389](https://issues.apache.org/jira/browse/BEAM-7389) for updates. +## Example + +In the following example, we create a pipeline with a `PCollection` of key-value pairs. +Then, we apply `Keys` to extract the keys and discard the values. + +```py +{% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/keys.py tag:keys %}``` + +Output `PCollection` after `Keys`: + +``` +{% github_sample /apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/keys_test.py tag:icons %}``` + +<table> + <td> + <a class="button" target="_blank" + href="https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/snippets/transforms/element_wise/keys.py"> + <img src="https://www.tensorflow.org/images/GitHub-Mark-32px.png" + width="20px" height="20px" alt="View on GitHub" /> + View on GitHub + </a> + </td> +</table> +<br> + +## Related transforms -## Related transforms * [KvSwap]({{ site.baseurl }}/documentation/transforms/python/elementwise/kvswap) swaps the key and value of each element. * [Values]({{ site.baseurl }}/documentation/transforms/python/elementwise/values) for extracting the value of each element. +<table> + <td> + <a class="button" target="_blank" + href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.util.html#apache_beam.transforms.util.Keys"> + <img src="https://beam.apache.org/images/logos/sdks/python.png" + width="20px" height="20px" alt="Pydoc" /> + Pydoc + </a> + </td> +</table> +<br>