DataFrame#
DataFrame#
A DataFrame is the core abstraction of the PyFlink DataFrame API. It wraps a PyFlink Table and provides a pandas-like interface for data transformations. All transformation methods return a new DataFrame.
Example:
>>> import pyflink.dataframe as pf
>>> df = pf.from_dict({"id": [1, 2], "name": ["a", "b"]})
>>> result = df.select("id", "name") \
... .with_column("id_doubled", pf.col("id") * 2) \
... .filter(pf.col("id") > 0) \
... .rename({"id": "identifier"})
Selection and Projection#
Create, reshape, rename, and redistribute DataFrame columns.
|
Select columns from the DataFrame. |
|
Add a new column or replace an existing column. |
|
Add multiple columns or replace existing columns. |
|
Drop columns from the DataFrame. |
|
Drop columns from the DataFrame. |
|
Rename columns. |
|
Rename columns. |
Explicitly redistribute rows across downstream parallel subtasks in round-robin fashion. |
Filtering and Missing Values#
Filter rows and handle duplicate, null, or NaN values.
|
Filter rows based on a predicate. |
|
Filter rows based on a predicate. |
|
Drop duplicate rows, keeping one row per group of |
|
Drop rows containing null values. |
|
Drop rows containing NaN values in float columns. |
|
Replace null values with a given value. |
|
Replace NaN values with a given value in float columns. |
Aggregation#
Aggregate the entire DataFrame or aggregate rows after grouping.
|
Group the DataFrame by columns. |
|
Apply aggregation expressions to the entire DataFrame. |
Join and Set Operations#
Combine DataFrames by keys, lateral table functions, or set algebra.
|
Join with another DataFrame. |
|
ASOF join with a dimension table at a time attribute. |
|
Join with an element-wise UDTF call. |
|
Union with another DataFrame, removing duplicate rows. |
|
Union with another DataFrame, preserving duplicate rows. |
|
Return rows from this DataFrame that do not exist in another DataFrame. |
|
Return rows from this DataFrame that do not exist in another DataFrame. |
|
Intersect with another DataFrame, removing duplicate rows. |
|
Intersect with another DataFrame, preserving duplicate rows. |
Row, Batch, and Function Operations#
Apply Python functions, batch functions, or table functions to DataFrame rows.
|
Expand one ARRAY, MAP, or MULTISET column into rows. |
|
Apply a function to each row, producing a new DataFrame. |
|
Apply a function to batches of rows, producing a new DataFrame. |
|
Apply a row-based UDTF to each row, producing zero or more rows. |
|
Apply a chainable function to the DataFrame. |
Conversion and Collection#
Convert DataFrames to other objects or collect bounded results locally.
Convert to a PyFlink Table. |
|
Convert to a Pandas DataFrame. |
|
Collect the DataFrame results to a list. |
|
Limit the DataFrame to the first n rows. |
|
Skip the first n rows of the DataFrame. |
|
Return the first n rows as a new DataFrame. |
|
Return an iterator over rows of the DataFrame. |
|
|
Return an iterator of pandas DataFrames, each containing up to batch_size rows. |
|
Print the AST and execution plan of this DataFrame. |
Properties#
Inspect DataFrame metadata and access AI helper methods.
Access LLM / AI functions. |
|
Get the schema of the DataFrame. |
|
Get the column names. |
GroupedDataFrame#
A DataFrame that has been grouped on a set of grouping keys.
|
Apply aggregation expressions. |
Expressions#
Helper functions to create column references, literal values, and time markers.
|
Create a column reference expression. |
|
Create a literal expression. |
|
Return a processing-time marker for DataFrame.join_asof. |