diff --git a/learning/katas/python/Core Transforms/GroupByKey/GroupByKey/task.py b/learning/katas/python/Core Transforms/GroupByKey/GroupByKey/task.py index 2832de39cad42..0d1308bd2279d 100644 --- a/learning/katas/python/Core Transforms/GroupByKey/GroupByKey/task.py +++ b/learning/katas/python/Core Transforms/GroupByKey/GroupByKey/task.py @@ -27,13 +27,17 @@ # - group # - strings -# [START groupbykey] -import apache_beam as beam +def groupbykey(): + # [START groupbykey] + import apache_beam as beam -with beam.Pipeline() as p: + with beam.Pipeline() as p: - (p | beam.Create(['apple', 'ball', 'car', 'bear', 'cheetah', 'ant']) - | beam.Map(lambda word: (word[0], word)) - | beam.GroupByKey() - | beam.LogElements()) -# [END groupbykey] + (p | beam.Create(['apple', 'ball', 'car', 'bear', 'cheetah', 'ant']) + | beam.Map(lambda word: (word[0], word)) + | beam.GroupByKey() + | beam.LogElements()) + # [END groupbykey] + +if __name__ == '__main__': + groupbykey() diff --git a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py index ec93563928da5..bb3f413a5c954 100644 --- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py +++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximatequantiles.py @@ -20,7 +20,7 @@ # pylint:disable=line-too-long # beam-playground: -# name: AppromximateQuantiles +# name: ApproximateQuantiles # description: Demonstration of ApproximateQuantiles transform usage. # multifile: false # default_example: false @@ -34,7 +34,7 @@ def approximatequantiles(test=None): - # [START quantiles] + # [START approximatequantiles] import apache_beam as beam with beam.Pipeline() as pipeline: diff --git a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py index 2bd0afcdb108c..120129f9955b9 100644 --- a/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py +++ b/sdks/python/apache_beam/examples/snippets/transforms/aggregation/approximateunique.py @@ -20,7 +20,7 @@ # pylint:disable=line-too-long # beam-playground: -# name: AppromximateUnique +# name: ApproximateUnique # description: Demonstration of ApproximateUnique transform usage. # multifile: false # default_example: false diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md b/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md index 95f66490f5eba..2c1864087066e 100644 --- a/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md +++ b/website/www/site/content/en/documentation/transforms/python/aggregation/approximatequantiles.md @@ -19,7 +19,7 @@ limitations under the License. {{< localstorage language language-py >}} -{{< button-pydoc path="apache_beam.transforms.stat" class="ApproximateQuantile" >}} +{{< button-pydoc path="apache_beam.transforms.stats" class="ApproximateQuantiles" >}} ## Examples @@ -28,3 +28,7 @@ limitations under the License. {{< /playground >}} ## Related transforms + +N/A + +{{< button-pydoc path="apache_beam.transforms.stats" class="ApproximateQuantiles" >}} diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md b/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md index dae287198fe53..242c27d6c1d0c 100644 --- a/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md +++ b/website/www/site/content/en/documentation/transforms/python/aggregation/approximateunique.md @@ -14,11 +14,12 @@ 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. --> + # ApproximateUnique {{< localstorage language language-py >}} -{{< button-pydoc path="apache_beam.transforms.stat" class="ApproximateUnique" >}} +{{< button-pydoc path="apache_beam.transforms.stats" class="ApproximateUnique" >}} ## Examples @@ -27,3 +28,7 @@ limitations under the License. {{< /playground >}} ## Related transforms + +N/A + +{{< button-pydoc path="apache_beam.transforms.stats" class="ApproximateUnique" >}} diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md b/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md index c9d6a7ac6d07e..8edf83f8a71bf 100644 --- a/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md +++ b/website/www/site/content/en/documentation/transforms/python/aggregation/batchelements.md @@ -19,7 +19,7 @@ limitations under the License. {{< localstorage language language-py >}} -{{< button-pydoc path="apache_beam.transforms.stat" class="BatchElements" >}} +{{< button-pydoc path="apache_beam.transforms.util" class="BatchElements" >}} ## Examples @@ -28,4 +28,7 @@ limitations under the License. {{< /playground >}} ## Related transforms + * [GroupIntoBatches](/documentation/transforms/python/aggregation/groupintobatches) batches elements by key + +{{< button-pydoc path="apache_beam.transforms.util" class="BatchElements" >}} diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/count.md b/website/www/site/content/en/documentation/transforms/python/aggregation/count.md index a444cd4b3dd94..9aab13e2218c6 100644 --- a/website/www/site/content/en/documentation/transforms/python/aggregation/count.md +++ b/website/www/site/content/en/documentation/transforms/python/aggregation/count.md @@ -46,7 +46,7 @@ We use `Count.PerKey()` to count the elements for each unique key in a `PCollect ### Example 3: Counting all unique elements -We use `Count.PerElement()` to count the only the unique elements in a `PCollection`. +We use `Count.PerElement()` to count only the unique elements in a `PCollection`. {{< playground height="700px" >}} {{< playground_snippet language="py" path="SDK_PYTHON_CountPerElement" show="count_per_element" >}} diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md b/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md index e3f287da7d049..1a5fa2ded7fb4 100644 --- a/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md +++ b/website/www/site/content/en/documentation/transforms/python/aggregation/groupbykey.md @@ -33,7 +33,7 @@ See more information in the [Beam Programming Guide](/documentation/programming- We use `GroupByKey` to group all the produce for each season. {{< playground height="700px" >}} -{{< playground_snippet language="py" path="SDK_PYTHON_GroupByKey" show="groupbykeysort" >}} +{{< playground_snippet language="py" path="SDK_PYTHON_GroupByKeySort" show="groupbykey" >}} {{< /playground >}} **Example 2**: diff --git a/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md b/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md index cfed995807961..1fd3e8dc48b54 100644 --- a/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md +++ b/website/www/site/content/en/documentation/transforms/python/aggregation/tolist.md @@ -1,5 +1,5 @@ --- -title: "BatchElements" +title: "ToList" --- -# BatchElements +# ToList {{< localstorage language language-py >}} @@ -26,3 +26,9 @@ limitations under the License. {{< playground height="700px" >}} {{< playground_snippet language="py" path="SDK_PYTHON_ToList" show="tolist" >}} {{< /playground >}} + +## Related transforms + +N/A + +{{< button-pydoc path="apache_beam.transforms.combiners" class="ToList" >}} diff --git a/website/www/site/content/en/documentation/transforms/python/overview.md b/website/www/site/content/en/documentation/transforms/python/overview.md index c5d9714e695ee..34599ed6c025a 100644 --- a/website/www/site/content/en/documentation/transforms/python/overview.md +++ b/website/www/site/content/en/documentation/transforms/python/overview.md @@ -50,7 +50,7 @@ limitations under the License. TransformDescription ApproximateQuantilesGiven a distribution, find the approximate N-tiles. ApproximateUniqueGiven a pcollection, return the estimated number of unique elements. - BatchElementsGiven a pcollection, return the estimated number of unique elements. + BatchElementsTransform that batches elements for amortized processing. CoGroupByKeyTakes several keyed collections of elements and produces a collection where each element consists of a key and all values associated with that key. CombineGloballyTransforms to combine elements. CombinePerKeyTransforms to combine elements for each key. diff --git a/website/www/site/layouts/partials/section-menu/en/documentation.html b/website/www/site/layouts/partials/section-menu/en/documentation.html index df4a0f20d636b..15140419a42e8 100755 --- a/website/www/site/layouts/partials/section-menu/en/documentation.html +++ b/website/www/site/layouts/partials/section-menu/en/documentation.html @@ -326,6 +326,7 @@