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

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

                Author: ASF GitHub Bot
            Created on: 29/Jul/20 07:44
            Start Date: 29/Jul/20 07:44
    Worklog Time Spent: 10m 
      Work Description: rosetn commented on a change in pull request #12394:
URL: https://github.com/apache/beam/pull/12394#discussion_r461945463



##########
File path: 
website/www/site/content/en/documentation/transforms/python/aggregation/latest.md
##########
@@ -14,10 +14,61 @@ 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.
 -->
+
 # Latest
 
+{{< localstorage language language-py >}}
+
+{{< button-pydoc path="apache_beam.transforms.combiners" class="Latest" >}}
+
+Gets the element with the latest timestamp.
+
 ## Examples
-See [BEAM-7390](https://issues.apache.org/jira/browse/BEAM-7390) for updates. 
+
+In the following examples, we create a pipeline with a `PCollection` of 
produce with a timestamp for their harvest date.
+
+We use `Latest` to get the element with the latest timestamp from the 
`PCollection`.
+
+### Example 1: Latest element globally
+
+We use `Latest.Globally()` to get the element with the latest timestamp in the 
entire `PCollection`.
+
+{{< highlight py >}}
+{{< code_sample 
"sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py" 
latest_globally >}}
+{{< /highlight >}}
+
+{{< paragraph class="notebook-skip" >}}
+Output:
+{{< /paragraph >}}
+
+{{< highlight class="notebook-skip" >}}
+{{< code_sample 
"sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest_test.py"
 latest_element >}}
+{{< /highlight >}}
+
+{{< buttons-code-snippet
+  
py="sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py" 
>}}
+
+### Example 2: Latest elements for each key
+
+We use `Latest.PerKey()` to get the elements with the latest timestamp for 
each key in a `PCollection` of key-values.
+
+{{< highlight py >}}
+{{< code_sample 
"sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py" 
latest_per_key >}}
+{{< /highlight >}}
+
+{{< paragraph class="notebook-skip" >}}
+Output:
+{{< /paragraph >}}
+
+{{< highlight class="notebook-skip" >}}
+{{< code_sample 
"sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest_test.py"
 latest_elements_per_key >}}
+{{< /highlight >}}
+
+{{< buttons-code-snippet
+  
py="sdks/python/apache_beam/examples/snippets/transforms/aggregation/latest.py" 
>}}
 
 ## Related transforms 
-* [Sample](/documentation/transforms/python/aggregation/sample) to combine 
elements. takes samples of the elements in a collection.
\ No newline at end of file
+
+* [Sample](/documentation/transforms/python/aggregation/sample) to combine 
elements. takes samples of the elements in a collection.

Review comment:
       Outside of the diff, but this is incorrect
   
   "Randomly takes some number of elements in a collection."




----------------------------------------------------------------
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:
[email protected]


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

    Worklog Id:     (was: 463919)
    Time Spent: 23h 10m  (was: 23h)

> 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: 23h 10m
>  Remaining Estimate: 0h
>
> Merge aggregation Colabs into the transform catalog



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

Reply via email to