Ctrl+K
Logo image Logo image

Site Navigation

  • API Reference
  • Examples

Site Navigation

  • API Reference
  • Examples

Section Navigation

  • PyFlink DataFrame
    • DataFrame
    • DataFrame Creation
    • Input / Output
    • SQL
    • Data Types
    • User Defined Functions
    • Configuration
    • Catalog
    • GPU Support
    • AI / LLM
    • Multimodal Expressions
  • PyFlink Multimodal
  • PyFlink Table
  • PyFlink DataStream
  • PyFlink Common

pyflink.dataframe.DataFrame.agg#

DataFrame.agg(*aggs: pyflink.table.expression.Expression, **named_aggs: pyflink.table.expression.Expression) → pyflink.dataframe.dataframe.DataFrame[source]#

Apply aggregation expressions to the entire DataFrame.

Parameters
  • *aggs – Aggregation expressions.

  • **named_aggs – Named aggregation expressions. Each expression is aliased to the corresponding keyword.

Returns

A new DataFrame with aggregation results.

Example::
>>> import pyflink.dataframe as pf
>>> df = pf.from_records(
...     [(1, 10), (2, 20), (3, 30)],
...     schema=["order_id", "amount"],
... )
>>> result = df.agg(
...     pf.col("order_id").count.alias("order_count"),
...     pf.col("amount").sum.alias("total_amount"),
... )
>>> result = df.agg(
...     order_count=pf.col("order_id").count,
...     total_amount=pf.col("amount").sum,
... )
>>> # result columns: ["order_count", "total_amount"]

previous

pyflink.dataframe.DataFrame.group_by

next

pyflink.dataframe.DataFrame.join

Show Source

Created using Sphinx 4.5.0.