pyflink.dataframe.from_records#
- from_records(data: Sequence[Union[Sequence[Any], Mapping[str, Any]]], schema: Optional[List[str]] = None) pyflink.dataframe.dataframe.DataFrame[source]#
Create a DataFrame from a sequence of records.
- Parameters
data – A sequence of records. Each record can be: - A sequence (tuple/list) of values - A dictionary with column names as keys
schema – Column names. Required when data contains sequences. Ignored when data contains dictionaries (keys become column names).
- Returns
A new DataFrame.
- Example::
>>> import pyflink.dataframe as pf >>> # From list of dicts >>> df = pf.from_records([{"a": 1, "b": "x"}, {"a": 2, "b": "y"}])
>>> # From list of tuples with schema >>> df = pf.from_records([(1, "x"), (2, "y")], schema=["a", "b"])