You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/08/01 02:35:00 UTC

[jira] [Work logged] (BEAM-7390) Colab examples for aggregation transforms (Python)

     [ https://issues.apache.org/jira/browse/BEAM-7390?focusedWorklogId=465244&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-465244 ]

ASF GitHub Bot logged work on BEAM-7390:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 01/Aug/20 02:34
            Start Date: 01/Aug/20 02:34
    Worklog Time Spent: 10m 
      Work Description: rosetn commented on a change in pull request #12437:
URL: https://github.com/apache/beam/pull/12437#discussion_r463910182



##########
File path: website/www/site/content/en/documentation/transforms/python/aggregation/mean.md
##########
@@ -16,23 +16,64 @@ limitations under the License.
 -->
 
 # Mean
-<table align="left">
-    <a target="_blank" class="button"
-        href="https://beam.apache.org/releases/pydoc/current/apache_beam.transforms.combiners.html?highlight=mean#apache_beam.transforms.combiners.Mean">
-      <img src="https://beam.apache.org/images/logos/sdks/python.png" width="20px" height="20px"
-           alt="Pydoc" />
-     Pydoc
-    </a>
-</table>
-<br><br>
 
+{{< localstorage language language-py >}}
+
+{{< button-pydoc path="apache_beam.transforms.combiners" class="Mean" >}}
 
 Transforms for computing the arithmetic mean of the elements in a collection,
 or the mean of the values associated with each key in a collection of
 key-value pairs.
 
 ## Examples
-See [BEAM-7390](https://issues.apache.org/jira/browse/BEAM-7390) for updates. 
 
-## Related transforms 
-* [CombineGlobally](/documentation/transforms/python/aggregation/combineglobally) to combine elements.
\ No newline at end of file
+In the following example, we create a pipeline with a `PCollection`.
+Then, we get the element with the maximum value in different ways.
+
+### Example 1: Maximum element in a PCollection
+
+We use `Mean.Globally()` to get the average of the elements from the *entire* `PCollection`.
+
+{{< highlight py >}}
+{{< code_sample "sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean.py" mean_globally >}}
+{{< /highlight >}}
+
+{{< paragraph class="notebook-skip" >}}
+Output:
+{{< /paragraph >}}
+
+{{< highlight class="notebook-skip" >}}
+{{< code_sample "sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean_test.py" mean_element >}}
+{{< /highlight >}}
+
+{{< buttons-code-snippet
+  py="sdks/python/apache_beam/examples/snippets/transforms/aggregation/mean.py" >}}
+
+### Example 2: Maximum elements for each key
+
+We use `Mean.PerKey()` to get the avareage of the elements for each unique key in a `PCollection` of key-values.

Review comment:
       Replace "avareage" with "average"




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 465244)
    Time Spent: 24.5h  (was: 24h 20m)

> Colab examples for aggregation transforms (Python)
> --------------------------------------------------
>
>                 Key: BEAM-7390
>                 URL: https://issues.apache.org/jira/browse/BEAM-7390
>             Project: Beam
>          Issue Type: Improvement
>          Components: website
>            Reporter: Rose Nguyen
>            Priority: P3
>          Time Spent: 24.5h
>  Remaining Estimate: 0h
>
> Merge aggregation Colabs into the transform catalog



--
This message was sent by Atlassian Jira
(v8.3.4#803005)