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/01/02 07:19:00 UTC

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

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

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

                Author: ASF GitHub Bot
            Created on: 02/Jan/20 07:18
            Start Date: 02/Jan/20 07:18
    Worklog Time Spent: 10m 
      Work Description: alexvanboxel commented on pull request #10179: [BEAM-7390] Add code snippet for Top
URL: https://github.com/apache/beam/pull/10179#discussion_r362385584
 
 

 ##########
 File path: sdks/python/apache_beam/examples/snippets/transforms/aggregation/top.py
 ##########
 @@ -0,0 +1,153 @@
+# coding=utf-8
+#
+# 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.
+#
+
+from __future__ import absolute_import
+from __future__ import print_function
+
+
+def top_largest(test=None):
+  # [START top_largest]
+  import apache_beam as beam
+
+  with beam.Pipeline() as pipeline:
+    largest_elements = (
+        pipeline
+        | 'Create numbers' >> beam.Create([3, 4, 1, 2])
+        | 'Largest N values' >> beam.combiners.Top.Largest(2)
+        | beam.Map(print)
+    )
+    # [END top_largest]
+    if test:
+      test(largest_elements)
+
+
+def top_largest_per_key(test=None):
+  # [START top_largest_per_key]
+  import apache_beam as beam
+
+  with beam.Pipeline() as pipeline:
+    largest_elements_per_key = (
+        pipeline
+        | 'Create produce' >> beam.Create([
+            ('🥕', 3),
 
 Review comment:
   although having emoji's in code looks cool, I think it could be problematic for some code editors.
 
----------------------------------------------------------------
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: 365264)
    Time Spent: 8h 20m  (was: 8h 10m)

> 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
>            Assignee: David Cavazos
>            Priority: Minor
>          Time Spent: 8h 20m
>  Remaining Estimate: 0h
>
> Merge aggregation Colabs into the transform catalog



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